- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
How to create recent posts page
April 8, 2011
This tutorial will show you how to create a recent posts list page in WordPress. In other words you’ll learn how to create a page that will display recent posts title in a list format.
Before you start this tutorial please make sure you learned how to add pages and create page templates in WordPress.
1. Access your theme directory (wp-content/themes/theme###)
2. Create new page, create new page template and assign it to the page.
3. Open the created page template file
4. To display a posts list we’ll use the WordPress core tag wp_get_archives.
This tag has several arguments:
<?php $args = array(
'type' => 'monthly',
'limit' => ,
'format' => 'html',
'before' => ,
'after' => ,
'show_post_count' => false,
'echo' => 1 );
?>
You should insert the tag into your page template file and assign necessary arguments.
The following code will make your page display 20 recent posts:
<?php
/*
Template Name: Recent Posts
*/
?>
<?php get_header(); ?>
<div class="container">
<div class="indent">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>
<?php endwhile; ?>
</div>
</div>
<?php get_footer(); ?>
Let’s see some other usage examples:
Display posts for the last 12 months
<?php wp_get_archives('type=monthly&limit=12'); ?>
Display posts for the last 15 days
<?php wp_get_archives('type=daily&limit=15'); ?>
Display 20 last posts
<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>



