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