包含未发布帖子的 Wordpress 列表

Wordpress List with unpublished posts

我有 1 个 ul-list 来显示已经发布的帖子和那些将以不同风格出现的帖子。因此,我已经将帖子设置为将来在 wordpress 上发布的预定日期(状态:未来)

这是我正在使用的:

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

已经发布的帖子确实可以很好地显示,但未来的帖子不会。我需要在 wordpress 上编辑设置,还是我的代码有误?

非常感谢

get_posts() 函数中 post 状态的默认设置是 'publish'。如果您只想要未来的 post,则可以将其设置为 'future',如果您同时想要两者,则可以将其设置为 'publish, future':

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

有关详细信息,请查看 this and this one :)