I am using wordpress’s function the_excerpt(). It works fine, but in the result is only shows 5 of my post’s. How can I make it display all posts instead of only the 5 most recent?
My code:
<?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; ?>
Your problem is not with
the_excerpt()
but rather withget_posts()
, since that is the array your loop is iterating over.Try: