If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)

captcha

How to create recent posts page

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'); ?>