Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Display a List of Last Updated Posts in WordPress

I remember the time I spent an entire weekend updating some of my most popular articles with fresh tips and new screenshots. I was so proud of the work, but I realized no one was seeing it.

My freshly updated posts were still buried on page 10 of my blog archives, sorted by their original publication date. It felt like all my hard work was invisible.

This is a common problem with the default WordPress setup. It’s great for a simple chronological blog, but it hides your valuable, updated content from your readers. This can make your site feel outdated, even when you’re working hard to keep it current.

Luckily, there’s a simple fix. By creating a list of your most recently modified posts, you can spotlight your best content and create a more engaging experience for your visitors.

In this guide, I’ll show you exactly how I do this on my own websites. I’ll cover an easy plugin method and a custom code solution for those who want more control.

How to Display a List of Last Updated Posts in WordPress

Why Display Last Updated Posts in WordPress?

Displaying your last updated posts in WordPress helps you showcase your freshest content to visitors and search engines. It keeps your important, recently updated articles from getting buried deep in your blog archives.

Most WordPress themes show posts in reverse chronological order based on their publication date. While this is logical for a standard blog, it means an article you updated yesterday might be buried on page 10 of your archive, even though it contains your most current information.

This creates a poor user experience. Your visitors miss out on your best work, and you don’t get the full value from your content maintenance efforts.

On the other hand, creating a dedicated space for your most recently modified articles makes your site more engaging for visitors.

To help you get this set up, I’ll walk you through two different methods. You can use the quick links below to jump straight to the solution that works best for you:

Method 1: Using a Plugin to Display Last Updated Posts

The easiest way to display a list of your most recently updated posts is by using a plugin. This method is perfect for beginners because it doesn’t require any code and gives you visual control.

I recommend using the free Kadence Blocks plugin. I picked this one because it’s one of the most popular block plugins available and adds a suite of powerful new blocks to the editor. It works perfectly with any WordPress theme, classic or modern block-based.

I’ll show you how to use its highly customizable ‘Posts’ block because it can easily be configured to show recently modified posts instead of recently published ones.

Install and Activate the Plugin

First, you need to install and activate the Kadence Blocks plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

The great thing about using a block is that you can add it almost anywhere on your site. Next, I’ll show you how to add it to a single page, a classic theme widget area like the sidebar, or a block theme template part.

Add the Posts Block to a Single Post or Page

If you want to add the list to a single page or post, simply open it in the WordPress editor. Once there, click the plus (+) icon to add a new block.

In the search bar, type ‘Posts’ and then drag the Kadence Posts block onto the post or page.

Adding the Kadence Posts Block in the WordPress Editor

If you have a classic theme, then you can add the block as a widget to display it across your site.

From your WordPress dashboard, go to Appearance » Widgets.

Find the widget area you want to edit, like your ‘Sidebar,’ click the plus (+) icon, and add the Kadence ‘Posts’ block using drag and drop.

Adding the Kadence Posts Block to a Classic Theme Widget Area

For modern block themes, you will use the Full Site Editor.

Go to Appearance » Editor from your dashboard. In the editor’s left menu, select ‘Patterns’ and then find the Template Part you want to edit, such as your ‘Footer‘ or ‘Sidebar.’

Simply drag and drop the Kadence ‘Posts’ block where you want your list to appear.

Adding the Kadence Posts Block to a Block Theme Template Part
Configure the Block to Sort by Last Modified Date

Now for the important part. With the Posts block selected, you will see its settings in the right-hand sidebar. This is where we’ll tell it to order posts by the last updated date.

Under the ‘General’ tab in the block settings, find the setting labeled ‘Order By’. Click the dropdown menu and change it from ‘Newest to Oldest’ to ‘Modified Descending’.

Configuring the Kadence Posts Block to Order by Modified Date

The block will instantly update to show your recently updated posts.

You can also customize many other settings here, like the number of posts to display and whether to show the featured image or post excerpt.

Kadence Posts Block Settings

⚠️ Important: By default, the Kadence Posts block might display your posts in a grid. If you prefer a simple list, just look under the ‘General’ tab in the block settings for the ‘Layout’ options and select a list style.

When you’re finished, just click the ‘Update’ or ‘Save’ button. You can now visit your website to see your list of last updated posts live on your site.

Method 2: Using Custom Code to Display Last Updated Posts

If you’re comfortable with adding a bit of code and want complete control over the appearance of your list, then this method is for you. You can customize the exact HTML output, which is great for advanced styling.

The safest way to add code to your site is by using the free WPCode plugin. It’s the plugin I always use for custom snippets because it prevents you from making mistakes that could break your site and keeps your code safe during theme updates.

Note: The free version of WPCode has everything you need to follow this tutorial. As you get more comfortable with code, you can upgrade to the Pro version, which gives you helpful features like a cloud library for your snippets and smart conditional logic.

Step 1: Install WPCode and Create a New Snippet

First, install and activate the free WPCode plugin. If you need help, see our guide on how to install WordPress plugins.

Next, go to Code Snippets » Add Snippet from your dashboard and select ‘Add Your Custom Code (New Snippet)’.

Adding a Custom Snippet in WPCode

Next, you will need to choose your snippet’s code type. At the bottom of the screen, simply click the ‘PHP’ option.

Step 2: Add the Custom PHP Code

On the next screen, give your snippet a title, like ‘Last Updated Posts Shortcode’.

Adding a Snippet Title and Code in WPCode

Then, in the ‘Code Preview’ box, paste the following code:

function wpb_lastupdated_posts( $atts ) {
    // Initialize the output string to prevent "Undefined variable" warnings.
    $output_string = '';

    // Parse the shortcode attributes.
    // 'limit' is the attribute name, and 5 is its default value if not provided.
    $atts = shortcode_atts( array(
        'limit' => 5,
    ), $atts, 'lastupdated-posts' );

    // Sanitize the 'limit' attribute to ensure it's a positive integer.
    $posts_limit = intval( $atts['limit'] );
    if ( $posts_limit <= 0 ) {
        $posts_limit = 5; // Fallback to default if an invalid limit is provided.
    }

    // Query Arguments for WP_Query.
    $lastupdated_args = array(
        'orderby'             => 'modified',         // Order posts by their last modified date.
        'ignore_sticky_posts' => 1,                  // Exclude sticky posts from the list.
        'posts_per_page'      => $posts_limit,       // Set the number of posts to display based on the 'limit' attribute.
        'post_status'         => 'publish',          // Only retrieve published posts.
    );

    // Create a new WP_Query instance.
    $lastupdated_loop = new WP_Query( $lastupdated_args );

    // Check if there are any posts found by the query.
    if ( $lastupdated_loop->have_posts() ) {
        // Added the 'last-updated-posts' CSS class to the <ul> tag.
        $output_string .= '<ul class="last-updated-posts">'; // Start the unordered list with a CSS class.

        // Loop through each post found by the query.
        while ( $lastupdated_loop->have_posts() ) :
            $lastupdated_loop->the_post(); // Set up post data for the current post.

            // Append each post as a list item with its link, title, and modified date.
            $output_string .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a> ( ' . get_the_modified_date() . ') </li>';
        endwhile;

        $output_string .= '</ul>'; // Close the unordered list.
    } else {
        // Optional: Message to display if no recently updated posts are found.
        $output_string .= '<p>No recently updated posts found.</p>';
    }

    // Reset post data. This is crucial to restore the global post data
    // to the main query after running a custom query.
    wp_reset_postdata();

    // Return the generated HTML string.
    return $output_string;
}

// Add the shortcode.
// This registers the 'lastupdated-posts' shortcode to be handled by the 'wpb_lastupdated_posts' function.
add_shortcode( 'lastupdated-posts', 'wpb_lastupdated_posts' );

Let me quickly break down what this code does. It creates a function that uses ‘WP_Query‘, which is WordPress’s standard way to fetch posts from your database. We’ve set it to get posts ordered by their ‘modified’ date.

Then, it wraps this function in a shortcode, [lastupdated-posts], that you can use anywhere on your site.

Finally, wp_reset_postdata() restores the main WordPress query. This is an important best practice that prevents our custom code from accidentally breaking other functions on the page.

Now, scroll down to the ‘Insertion’ section and make sure the method is set to ‘Auto-Insert’ and the location is ‘Run Everywhere’. This is the standard setting for shortcodes and ensures WordPress will recognize it anywhere on your site.

WPCode's Insertion Options

The ‘Auto-Insert’ method with the ‘Run Everywhere’ location is the correct setup. This ensures WordPress will recognize your shortcode no matter where you decide to use it on your site.

Finally, toggle the switch at the top to ‘Active’ and click the ‘Save Snippet’ button.

Activating and Saving the Snippet in WPCode
Step 3: Add the Shortcode to Your Site

You can now add your list anywhere on your site that accepts shortcodes.

Simply edit a post or page, add a Shortcode block, and type in:

[lastupdated-posts]

This will display the default of 5 posts.

To show a different number, you can use the ‘limit’ parameter like this:

[lastupdated-posts limit="10"]

The code will produce a simple, unstyled list that inherits your theme’s default styling for links and list items. You can add custom CSS to your theme’s stylesheet to style the ‘.last-updated-posts’ class if you wish.

This is how it looks in a sidebar on my test website:

Last Updated Posts Example

Bonus: How to Display a ‘Last Updated’ Date on Single Posts

Besides showing a list on your homepage or sidebar, it’s also a great idea to display the ‘Last updated on’ date at the beginning of your articles. This immediately tells readers that the information is current and trustworthy, which I find builds a lot of credibility.

Preview of the last updated date shown in posts

Many popular themes have this option built in. Check your theme’s settings under Appearance » Customize. Look for settings related to Post Meta or Blog/Post Layout.

If your theme doesn’t have this option, you can easily add it. For a complete walkthrough, see our guide on how to display the last updated date for posts in WordPress.

Note: If you make these changes and don’t see your list appear right away, you may need to clear your WordPress cache.

Frequently Asked Questions About Showing Recently Updated Posts

Here are answers to some of the most common questions we get about showing recently updated posts.

1. Will updating a post affect its URL or SEO?

No, simply updating the content of a post does not change its URL (permalink). In fact, updating and improving your old content is a highly recommended SEO best practice that can improve your search rankings.

2. Can I exclude certain posts from the last updated list?

Yes. The Kadence block plugin we mentioned allows you to include or exclude specific categories right from the block settings. If you’re using the custom code method, you can modify the WP_Query arguments in the code snippet to exclude posts by a specific ID, category, or tag.

3. How is the modified date different from the published date?

The published date is the date the post was first made live on your site. The modified date is the date the post was last saved with any changes. A post can have a publication date from years ago, but a modification date from yesterday.

I hope this guide helped you learn how to display last updated posts in WordPress. You may also want to check out our guide on how to show related posts with thumbnails to keep your visitors engaged even longer, or our expert pick of the most useful WordPress widgets for your site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

39 CommentsLeave a Reply

  1. Is there any way to display dates in such way like fandom. Instead of saying “x date” it would be better as x hour or x days ago.

  2. Hi,
    i modified the code from “modified” to “date”. Then i noticed, that $lastupdated_loop->have_posts() is limited to the number of last posts which is presented on the main page. What is to do to get an (independent) number of f.e. 50 last posts? Instead of 6 as stored in the wp settings?

    • You should be able to change from line 12 of the code the section ‘&& $counter < 5' and change the 5 to the number of posts you want to show.

      Admin

      • Thank you, you can be sure, that this was the first thing i did. But notice that when you change the number in your code it is without result. Write f.e. ‘&& $counter <20' – this does not work as there is f.e. 6 in the wordpress settings. So the question is how to overwrite those settings temporarily or to find any other solution that works without corresponding to the max-posts-per-page settings in wordpress.

        • With your theme overriding the query that way, you could try adding a comma to the end of line 6 and on the next line add ‘posts_per_page’ => 20 to work on overriding your theme’s posts per page.

    • You would want to check with your eCommerce plugin for what options they would recommend as they normally have a widget or similar option.

      Admin

  3. Thank you for the instructions. That was exactly what I was looking for! Finally I can show the latest updates in my sidebar.

  4. Hi,

    It works well, but it does not respect the content permissions of the page. It turns all the content visible to anybody…

  5. Hi,

    I followed you ‘How to Create a Custom WordPress Widget’, including ‘Creating a Site-Specific WordPress Plugin’ and that works perfectly. Great tutorial as I now have the ‘Hello world’ text displaying as a sidebar.

    But this one has me completely stumped. I followed the tutorial as best I could but it just displays my ‘Hello world’ text, never any list of updated posts.

    Where in my custom plugin file do I put the function wpb_lastupdated_posts()? Where do I put the ‘add_shortcode’ and where do I put the ‘if (function_exists(wpb_lastupdated_posts)) : ‘ statement?

    Many thanks,
    Des

  6. Installed the code as stated. When using the short code- I add it to the bottom of the post. but when view the code- it puts the information on the top of the post. weird.

    • Same request here. I’m interested in listing recently updated Pages + showing the last_modified date. Ideally with some excerpt or number of characters from page.

  7. Great code, but is there anyway to get this exact same function but based on comments made by specific user (admin) and list the most recent comment made as the top of the threads in the list?

    Thanks!

  8. Hi… great post…. Yet I was wondering if you could give me a hand on something: I need to take the picture and title of the last three published posts and arrange them in some kind of Gallery (Just to show the latest three published articles, Any idea if there’s a plugin for that, I assume I can use the code you just placed above, but Im not quite sure on the DB structure)

    Thanks in advance… =)

  9. I do not know how to change the office location address on my WordPress web site. Try as I may, I cannot reach it to change it. http://www.mastheadpa.ca I would appreciate simple and straight answer. I can do most of the upkeep but that address change eludes me and i have not seen the key in the WP information and tutorials. help.

    • @Pierre your office location is stored inside a widget. Inside your WordPress admin area, go to Appearance » Widgets. On your right hand column you will see a list of widgets currently in use on your site. Look for Footer Widget Area and there you will see Get in Touch widget which you can edit and save your changes.

      Admin

  10. Hi, love this article but I don’t quite get what is meant to be updated when you mention ‘use it like this:
    1

    Which file is this?

    Steve

    • Some users might want to display last updated posts into different templates of their WordPress themes. Those users can use this code to add it. Other users can use the shortcode to add it in their posts, pages, and widgets.

      Admin

  11. Instead of using $counter for your loop, why don’t you just use the 'posts_per_page' attribute on the WP_Query args ?

    Mine goes like this:

    $lastupdated_args = array(
    ‘orderby’ => ‘modified’,
    ‘ignore_sticky_posts’ => 1,
    ‘posts_per_page’ => 5
    );

    Also, when I try the above code, it only give me one last modified post (not five as it should be).
    Wonder why …

  12. I love your articles but this one is way over my head. Are there any plugins for this? :)

    Sorry but I dont know the “innards” of the website and have broken my site when I tried a few things.

    It is a great idea though.Thanks for all you great work. Mary

    • The code above is actually a ‘plugin’. Simply copy and paste the first code in functionality plugin. Then, there are two ways to display the list of posts, either using template tag or the easiest, using [lastupdated-posts] shortcode.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.