Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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 ...
    endwhile;

    wp_reset_postdata();

else :

    // do normal news stuff ...

endif; 
share|improve this answer
add comment

Your Answer

 
discard

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.