WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using $_GET["post_type"] to direct my search to the correct templates and have used the following:

<?php $search_refer = $_GET["post_type"];
if ($search_refer == 'news') { load_template(TEMPLATEPATH . '/search-news.php'); }
elseif ($search_refer == 'members') { load_template(TEMPLATEPATH . '/search-members.php'); }; ?>

I need to add another elseif to this where the search refer is news but the posts have the status "future". Is it possible to do that?

The current news search refer needs to only show posts with the status "published".

share|improve this question
up vote 1 down vote accepted

I think you need to check status in your search-news.php template. And if $_GET['status'] is equal to future, create custom loop for it. Your search-news.php could look something like this:

if ( $_GET['status'] == 'future' ) :

    $the_query = new WP_Query( array(
        'post_type'   => 'news',
        'post_status' => 'future',
        // else arguments ...
    ) ); 

    while ( $the_query->have_posts() ) : $the_query->the_post();
        // do stuff ...


else :

    // do normal news stuff ...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.