• Hello WP advanced users!

    I have two categories where I post in but I want to use one category as a sort of Events page, it should have the same layout as the normal news though.

    Is it possible to display one category with $post_status = ‘future’; and where should I place this code?

    It works when I place it in index.php of my wordpress installation but than all my other posts on the site are not visible because it applies it to everything. I also tried this but it still applies to every post and not only category 3:

    $post_status = ‘future’;
    if (!isset($cat)) {
    $cat = “3”;
    }

    $post_status = ‘public’;
    if (!isset($cat)) {
    $cat = “4”;
    }

    Thanks a lot for the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Using query_posts, you’ll be able to set the post_status to future.

    Thread Starter fabrikgrafik

    (@fabrikgrafik)

    Thanks a lot for your reply, I tried this now and putted it in loop.php …

    query_posts(‘cat=3&post_status=future&order=ASC’);

    but now in both categories I see all future posts from both categories … while I only should see the future posts in “events category” and all news posts in “news category”

    Did I do something wrong?

    Use a conditional tag to set the query right before the loop starts (the if : while) like so:

    <?php
    if(is_category('3')) query_posts('cat=3&post_status=future&order=ASC');
    
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    ?>
    Thread Starter fabrikgrafik

    (@fabrikgrafik)

    Amazing! thanks a lot for helping me out here, I appreciate it a lot!

    It works now, I just have to figure out a way to fix something I did not think about.

    when there is an event planned on let’s say the 20th of october … the event will disappear from the site on the 19th, 24:00pm. It would be more logical, when it disappears the 20th, 24:00pm so people can browse the even info on the day of the event itself.

    I’ll google this .. and hopefully let you guys know the answer, unless someone else knows first!

    Thanks again

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘$post_status = 'future'; in a category?’ is closed to new replies.