Displaying Recent Posts with Summary
Some of my customers like to display recent posts with a title and a short description. There are multiple ways of accomplishing that.
The first way is:
<ul>
<?php query_posts(‘showposts=5′); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<li><?php the_excerpt(__(‘(more…)’)); ?></li>
<?php endwhile;?>
</ul>
And you make sure that the excerpt is a short description of the post. You must rewrite the excerpt to make it fit the word limit.
Another way is using the Word Limit which will save you the time of writing an excerpt because the Word Limit Plugin will automatically crop everything after the desired number of characters. For that you need to download a plugin called Limit-Post which you need to download and activate.
Once the plugin is activated paste the following code where you want it displayed in your theme files:
<ul>
<?php query_posts(‘showposts=5′); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<li><?php the_content_limit(250); ?></li>
<?php endwhile;?>
</ul>
You may change the 250 to set the character limit of your desire.
Please comment to show me your sites you have coded this on.
