How to Display Last Updated Date In GeneratePress Theme?

display last updated date in GeneratePress theme

The GeneratePress theme does not have a function to display last updated date on every blog post. Hence, in this article we are going to learn how to display last updated date in GeneratePress theme and also see how can we keep the published date as well.

Whatever we are going to see in this blog post applies to Generatepress free as well as its premium theme. If you want to learn more about the differences between both the versions. Have a look at our GeneratePress free vs premium article.

GeneratePress premium theme extends its functionality and allows you to enable post date, author name, category, etc. But, it does not offer any kind of post meta, that helps in showcasing published and last updated date.

Why Do We Need To Display Last Updated Date?

Unlike any other business or a service website offering products or services. Blogs and news sites have lot of information and need to be kept updated. So that readers get to read fresh content.

By default, WordPress keeps published and updated date for every blog post. Well, you just need to use the last modified date code in your theme, for WordPress to display it on each of your blog posts.

Displaying both published date and last update date is a good practice done for any website. Knowing the actual date of publish and updated date of the post, increases your readers trust factor towards you and your content.

You might even start getting returning visitors. Since, everyone needs updated information.

This is also a good SEO practice as per the search engine’s point of view. Search engines love to show fresh content to their users.

Few Benefits Of Displaying Last Updated Date

  • It increases trust factor
  • There is a good chance of returning visitors to come to your site
  • Increases your site’s CTR and decreases bounce rate.
  • Users get a better point of view with updated information compared to old info.
  • Search engine crawlers get notified about content update
  • Thereby, having a chance to climb up in the SERP position

I am using GeneratePress premium theme on my blog for demonstrating all the methods. You can even use free version of GeneratePress.

Display Last Updated Date In GeneratePress Theme Using Plugin

Using a plugin to perform such tasks is the most easiest and hassle free way if you are not comfortable with coding.

I personally, avoid plugins as mush as I can. If there’s something to be done by using small amount of code, I prefer coding it. Adding a lot of plugin to any site would just hurt the website’s performance.

But, nevertheless its okay for beginners to use plugins, as they lack the right amount knowledge.

The best plugin to accomplish this task is WP Last Modified Info.

WP Last Modified Info plugin to display last updated date in GeneratePress theme

WP Last Modified Info plugin automatically injects last updated info on your blog posts and pages. Moreover, it also inserts dateModified schema markup, telling search engines about the last modified date of a post.

Before going further, I would like you to see the date of one of my article on this website.

GeneratePress Review article on BloggingIdol

You can see that this article has been published on September 15th, 2020. We will be using this as a sample for further demonstrations.

Now let’s jump into the steps involved in using WP Last Modified Info

Steps To Install & Display Last Updated Date In GeneratePress Theme Using WP Last Modified Info

  • Go to your WordPress Dashboard and hover your mouse on Plugins.
  • Click on Add New
adding new plugin - WP Last Modified Info
  • Type WP Last Modified Info in the search bar.
  • Then press Install Now and Activate the plugin.
  • After the plugin has been activated this is what I see
GeneratePress Review – Last Updated Date: June 15, 2021
  • Since, I have done some updates to the article it showcases the date as June 15, 2021.

If you want to display Published Date & Last Updated Date simultaneously, in WP Last Modified Info plugin then follow the steps below.

  • Go to your WordPress Dashboard and hover your mouse on Settings then click on WP Last Modified Info.
WP Last Modified Info plugin settings to display both published date and updated date simultaneously
WP Last Modified Info plugin settings
  • Under Post Options, toggle the switch of Enable for Posts/Pages in Frontend from Red to Green.
  • This will display the Published Date and Last Updated Date of the blog post simultaneously.
wp last modified info plugin displaying published date and last updated date simultaneously
GeneratePress Review – Published Date & Last Updated Date simultaneously

That is how easy it is, this plugin works very well (Tried & Tested).

Before showing you the next method of displaying last updated date in GeneratePress theme, I will deactivate WP Last Modified Info plugin as we’d want to see the code take into effect.

deactivated wp last modified info plugin

Go to WordPress Dashboard -> Plugins -> Installed Plugins -> Deactivate WP Last Modified Info

Also Read:

Display Last Updated Date In GeneratePress Theme Via Code

For this technique, we will have to install Code Snippets plugin.

Installing Code Snippets Plugin

  • Go to your WordPress Dashboard, hover your mouse on Plugins and click on Add New.
  • Type Code Snippets in the search bar.
  • Install and Activate the plugin

Writing Code

  • After activating Code Snippets from your WordPress Dashboard hover your mouse on Snippets and click on Add New
adding new code snippet
Adding New Code Snippet
  • This will bring you to a New Snippet.
  • Give it a name (I’ve give Last Updated Date) and paste the code mentioned below
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';

    if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
        $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>';
    }

    $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_attr( get_the_modified_date( 'c' ) ),
        esc_html( get_the_modified_date() )
    );

    return sprintf( '<span class="posted-on">%s</span> ',
        $time_string
    );
}, 10, 2 );
  • Then click on Save Changes and Activate button.
  • Now let us check the date section of our article
displaying last updated date in GeneratePress theme via code
Code brought out the last updated date of the article

Woah, works amazingly well…

The only drawback I see in the above code is that it only displays last updated date and does not show you the article’s published date.

There is another code which can help you out with that problem. By the way, displaying last updated date and published date simultaneously is a personal choice. If you want you can stop right here, without going further. \

Display Last Updated Date & Published Date Simultaneously

If you are looking for a code that display’s both published date and last updated date then use the following code into Code Snippets.

add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';

    if ( get_the_date() !== get_the_modified_date() ) {
        $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time> | <time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>';
    }

    $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_attr( get_the_modified_date( 'c' ) ),
        esc_html( get_the_modified_date() )
    );

    return sprintf( '<span class="posted-on">%s</span> ',
        $time_string
    );
}, 10, 2 );

After adding the code, review the date on your blog posts.

displaying last updated date and published date at same time in generatepress theme
Last Updated Date & Published Date Simultaneously in GeneratePress theme

Your post should display last updated date and published date simultaneously.

Verifying Last Updated Date

After all of this has been done it is good to verify the Post using Google Structured Data Testing Tool and Rich Results Test Tool.

google structured data testing tool displaying last updated date and published date
Google Structured Data Testing Tool – datePublished & dateModified

This tool will soon get deprecated and you will be driven to Rich Results Tool. So, let us also test the blog post using Google smartphonebot and desktopbot.

rich results test using smartphone bot displaying last updated date in generatepress theme
Rich Results Test (smartphone) showing last updated date
rich results test using desktop bot displaying last updated date in generatepress theme
Rich Results Test (desktop) showing last updated date

Conclusion

I hope the methods shown in this tutorial will help you to display last updated date in GeneratePress theme. They can be done on any version of the GeneratePress themes.

If you still have any doubts regarding this article, please feel free to leave a comment.

Further Reading:

Ankur Purecha

I am in love with WordPress, building websites, doing SEO, and all that kind of stuff. I generally write about WordPress, Blogging, and SEO on BloggingIdol

Leave a Comment