You're here: Home » WordPress » Display Recent Posts with Excerpt

Display Recent Posts with Excerpt

On Aug 26, 2011 under WordPress

It’s a good idea to display recent post titles with a small excerpt instead of simply displaying plain post titles. Many ways are there in WordPress to show recent posts and here is one of those.

Paste the below code in your theme files where you want to show the recent posts. I prefer using it in footer (footer.php).

<ul>
<?php query_posts('showposts=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<li><?php the_excerpt(__('(Continue Reading)')); ?></li>
<?php endwhile;?>
</ul>

If you have written an excerpt in the Edit Post page, then the code uses that excerpt. If not, then it automatically creates excerpt from the beginning lines of the post.

Comments on this entry (3 comments)

Did you like this post? You can share your opinion with us! Simply click here.

  1. iSchack says:

    Hey there.
    Thanks for this post. A quick question: how can I limit how many characters from the beginning of the text are shown?
    I have a div of height x that I want to display the excerpt from the latest post in.
    Using your code, I end up with a text with a length that exceeds the height of the box it is in.

    Thanks for your help.

  2. Diego says:

    Thanks for this! =D

Leave a Reply

CommentLuv badge