0

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".

1 Answer 1

1

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; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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