我正在使用wordpress的功能the_excerpt()。它工作正常,但结果仅显示我帖子的5个。如何使其显示所有帖子,而不是仅显示5个最新帖子?
我的代码:
<?php
$lastposts = get_posts();
foreach ( $lastposts as $post ) :
setup_postdata( $post ); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p style="font-size:12;"><em>Post date: <?php the_date(); ?></em></p>
<?php the_excerpt() ?>
<a href="<?php echo get_permalink(); ?>"> Read more...</a>
wp_reset_postdata();
php endforeach; ?>
Run Code Online (Sandbox Code Playgroud)
您的问题不是the_excerpt()而是而是get_posts(),因为这是您的循环正在迭代的数组。
尝试:
<?php
$lastposts = get_posts(array('posts_per_page' => -1));
foreach ( $lastposts as $post ) :
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4998 次 |
| 最近记录: |