admin管理员组文章数量:1301581
Let's talk about the situation first. I have a query for finalists, some of which has a tag 'Special Mention'.
I need to move all posts with the tag to the end of loop. e.g. I have 13 posts, 3 of which has the tag. The last 3 (11, 12, 13) must be the posts with the tag.
On a side note, I also need pagination to work! Here's what I have so far:
$paged = (get_query_var('paged')) ? $paged = get_query_var('paged') : 1;
$args = [
'post_type' => 'winnerspt',
'posts_per_page' => 5,
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => [
[
'key' => 'award_category',
'value' => $category,
]
],
'paged' => $paged,
];
$finalists = new WP_Query($args);
if ($finalists->have_posts()): while($finalists->have_posts()): $finalists->the_post();
...
My pagination:
$GLOBALS['wp_query'] = $finalists;
the_posts_pagination( [
'prev_text' => '<span href="#" class="page-link" aria-label="Previous">
<i class="fas fa-chevron-circle-left fa-lg"></i>
</span>',
'next_text' => '<span href="#" class="page-link" aria-label="Next">
<i class="fas fa-chevron-circle-right fa-lg"></i>
</span>',
'before_page_number' => '<span href="#" class="mx-4 text-xl text-sub">',
'after_page_number' => '</span>',
'screen_reader_text' => ' '
] );
I've tried merging queries, but that seems to mess my pagination up. I feel like there's an easy way to do this, but I can't figure it out.
Thanks!
本文标签: customizationHow do I moveorder posts with a tag to the end
版权声明:本文标题:customization - How do I moveorder posts with a tag to the end? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741677330a2391960.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论