我想按缩略图显示帖子顺序,即首先显示有缩略图的帖子,然后显示没有缩略图的帖子。
我在 Stackoverflow 上发现了同样的情况,但这对我不起作用。目前我正在使用目录+主题,我想在其中实现它。
我尝试制作两个循环,一个循环将显示带缩略图的帖子,第二个循环将显示不带缩略图的帖子。但这在分页的情况下不起作用,因为没有缩略图的帖子应该在最后一页
这是代码
{var $itemQuery = array(
'post_type' => 'ait-item',
'posts_per_page' => $filterCountsSelected,
//'meta_key'=> '_thumbnail_id',
'tax_query' => array(
array(
'taxonomy' => 'ait-items',
'field' => 'term_id',
'terms' => $currentCategory->term_id
)
),
'paged' => $pagination,
)}
{customQuery as $query, $itemQuery}
{* Loop for categories with featured Image*}
{customLoop from $query as $post}
{if $post->image}
//Display post with thumbnail
{/if} //end of if
{/customLoop} //end of loop
{* Loop for categories without featured Image*}
{customLoop from $query as …Run Code Online (Sandbox Code Playgroud)