Skip to main content
WordPress made easy with the drag & drop Total WordPress Theme!Learn More

How to Show Recently Updated Posts In WordPress

Last updated on:
WordPress Is More Than A Blogging Platform

A lot of bloggers like to go back and re-work their old posts either to fix something or to include some new content to freshen up and improve the post. It’s a good habit not only to keep the quality of your content high, but updating older posts (especially the more popular and linked to posts) you can keep Google happy and help with your blog’s rankings.

Today’s post will show you how to display your recently updated posts with a plugin as well as how to create a custom query to display recently updated/modified posts anywhere on your site.

Show Recently Updated (Modified) Posts with a Query

If you are working on a theme or plugin and are looking for the code to display recently updated or modified posts, simply paste the following code wherever you want the posts to display.

<?php // Display recently updated posts ?>
<ul class="updated-posts">
	<?php
	// Show recently modified posts
	$recently_updated_posts = new WP_Query( array(
		'post_type'      => 'post',
		'posts_per_page' => 3
		'orderby'        => 'modified',
		'no_found_rows'  => true, // speed up query when we don't need pagination
	) );
	if ( $recently_updated_posts->have_posts() ) :
		while( $recently_updated_posts->have_posts() ) : $recently_updated_posts->the_post(); ?>
			<li><a href="<?php the_permalink(); ?>" title="<?php esc_attr( get_the_title() ); ?>"><?php the_title(); ?></a></li>
		<?php endwhile; ?>
		<?php wp_reset_postdata(); ?>
	<?php endif; ?>
</ul>

This code will display a simple ul list of the 3 most recently modified/updated posts with just the title and a link to the post. Make sure to edit the WP_Query parameters to best suit your needs. For example you can modify the query to display the recently updated posts from a specific category like the following example which pulls the latest modified posts from the “news” category:

<?php // Display recently updated posts from the news category ?>
<ul class="updated-posts">
	<?php
	// Show recently modified posts
	$recently_updated_posts = new WP_Query( array(
		'post_type'      => 'post',
		'posts_per_page' => 3
		'orderby'        => 'modified',
		'no_found_rows'  => true, // speed up query when we don't need pagination
		'category_name'  => 'news', // Only display posts from the category with the slug "news"
	) );
	if ( $recently_updated_posts->have_posts() ) :
		while( $recently_updated_posts->have_posts() ) : $recently_updated_posts->the_post(); ?>
			<li><a href="<?php the_permalink(); ?>" title="<?php esc_attr( get_the_title() ); ?>"><?php the_title(); ?></a></li>
		<?php endwhile; ?>
		<?php wp_reset_postdata(); ?>
	<?php endif; ?>
</ul>

Optimization: Notice how we are using both post_type and no_found_rows parameters in our query? This helps speed up the query. By telling WordPress you are specifically querying the standard “post” type it prevents an extra check and by setting adding the no_found_rows parameter to true you are telling WordPress to not do all the extra work needed for Queries that require pagination.

Bonus: Show Post’s Last Modified Date & Time

You can also display the modified date and time of any post within the loop using something like this:

<p>Modified: <?php the_modified_date(); ?> at <?php the_modified_time(); ?></p>

But remember if your post hasn’t been modified then the modified date & time will be the same as the published date.

Display Recently Updated Posts with a Plugin

Recent Posts Widget Extended Plugin

If you want to skip the code you can always install a simple recent posts widget with order options to display your posts. We like the Recent Posts Widget Extended free WordPress plugin. This simple and flexible plugin makes it easy to display your posts with a widget or shortcode, and there is even an option to order your posts by different variable. You can also use the plugin to customize the image cropping, display excerpt, set the title URL and more.

Subscribe to the Newsletter

Get our latest news, tutorials, guides, tips & deals delivered to your inbox.

2 Comments

  1. Jord

    Only a little snippet but exactly what i needed!

  2. luciole135

    I published a plugin that does the same thing (and more efficient) in November 2014. It is on the repertory of WordPress here:

    https://wordpress.org/plugins/recently-updated-posts-widget/

Leave a Reply

Your email address will not be published. Required fields are marked *

Learn how your comment data is processed by viewing our privacy policy here.