Wordpress:获取一页上所有帖子的链接

Gad*_*i A 2 wordpress

我想在我的博客中添加一个页面,其中包含指向博客中所有帖子的链接.不仅是页面中的10个或者其他东西,而是所有这些(如果这是一个坏主意我会有兴趣知道为什么).

除了链接,每个帖子的名称和日期也会很好.

nop*_*ies 7

这样的事情应该做到;

<?php
$args = array( 'numberposts' => -1, 'orderby' => 'post_date' );
$postslist = get_posts( $args );
foreach ($postslist as $post) :  setup_postdata($post); ?> 
    <div>
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
              <br />  
            <?php the_date(); ?>
            <br />  
          <?php the_excerpt(); ?>
   </div>
<?php endforeach; ?>
Run Code Online (Sandbox Code Playgroud)

请注意,get_posts()的默认'orderby'参数实际上是'post_date'.为了清楚起见,我刚刚添加了它.看看如何配置the_date().

我同意上面关于分页的评论.如果你有很多帖子,它可能会变得笨拙.