WordPress List with unpublished posts

I have 1 ul-list to display the posts already published and those that’ll come in different styles. Therefore I already have the posts set to a scheduled date in future to be published on wordpress (status: future)

This is what I am using:

Read More
<ul>
// Here come the already published posts - this one works 
    <li class="bereits">Bereits erschienen</li>
    <?php 
    if ( get_post_status ( $ID ) == 'publish' ) {
        $args=array( 'posts_per_page'=>9, 'offset'=> 0, 'category' => '','orderby'=> 'post_date','order'=> 'ASC', ); 
        $seiten = get_posts( $args ); 

        foreach ( $seiten as $post ) : setup_postdata( $post ); ?>

        <li class="aktiv">
            <a href="<?php the_permalink(); ?>">
               <?php the_title(); ?>
            </a>
        </li>

        // And here shall come the future posts - doesn't work
        <?php endforeach; wp_reset_postdata(); 

    } else { ?>

       <li class="nochnicht">Noch nicht erschienen</li> 
       <?php
       $args_inaktiv=array( 'posts_per_page'=>9, 'offset'=> 0, 'category' => '','orderby'=> 'post_date','order'=> 'ASC', ); 
       $seiten_inaktiv = get_posts( $args_inaktiv ); 

       foreach ( $seiten_inaktiv as $post ) : setup_postdata( $post ); ?>

        <li class="inaktiv">
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </li>
       <?php endforeach; wp_reset_postdata();
    } ?>
</ul>

The posts that are already published do get displayed nicely, but the futurous ones not. Do I need to edit a setting on wordpress, or is my code wrong?

Thanks so much

Related posts

Leave a Reply

1 comment

  1. The default setting for the post status in the get_posts() function is ‘publish’. You can set this to ‘future’ if you only want future posts, or to ‘publish, future’ if you want both:

    $args=array('posts_per_page'=>9, 'offset'=> 0, 'category' => '','orderby'=> 'post_date','order'=> 'ASC', 'post_status' => 'publish,future' );
    

    For more info, check this and this one 🙂