Placing dynamic post excerpts onto a static page template
If you require a page (home or otherwise) that contains editable content plus a dynamic list of excerpts of new posts then read on (wordpress).
Copy and paste page.php into a text editor and place the following code into the top. This will ensure that ‘yourpagename’ will appear in the list of templates in your page creation/editing form for you to choose. Then save as that name and place back in the theme directory that you are using…
<?php /* Template Name: yourpagename */ ?> ~
Then place the following code wherever you want the list of excerpts to appear – normally below the loop that is already there. This will create another loop that will show 5 posts in the category ‘news’ with a title ‘my latest news’. Please edit any of these to suit your needs.
If you want all types of posts to show leave out category_name=news&
<h3>My latest posts</h3>
<?php $temp_query = $wp_query; ?>
<?php query_posts('category_name=news&showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>
You can add as much or as little to the loop as you like in the way of text or php calls. It can be wrapped in a styling class and have a border, background or different fonts etc But that’s a whole other story called CSS and quite frankly my day just isn’t long enough to get into that right now…