2

I'm creating a website where I have a need to show a set of posts from a custom loop but I need to display a specific post first.

This post will be dynamically specified in the URI by a $_GET variables. Basically, if that $_GET variable is set, it will contain the ID of the post that I need to display first. I need to somehow modify my custom query to show this post first, then carry on with the rest of the query ordering by date.

Having looked at the WP docs, I can't see a way to do this and my Googling has failed me.

My query is set up as follows:

$review_args = array(
    'post_type' => 'surgeonreviews',
    'posts_per_page' => -1,
    'meta_key' => $meta_key,
    'orderby' => $sortby,
    'order' => $order,
    'date_query' => array(
        array(
            'month' => $_GET['review-month'],
            'year' => $_GET['review-year']
        )
    ),
    'meta_query' => array(
        array(
            'key' => 'LESC_SurgeonId',
            'value' => $post_meta['LES_SurgeonId'][0]
        ),
        array(
            'key' => 'LESC_Rating',
            'value' => $_GET['rating'],
            'compare' => '>='
        )
    )
);

Is there any way to achieve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.