How To Display The Last Updated Date In GeneratePress Theme?

In this article, I will show you how you can show last updated date in GeneratePress theme.

Whether you want to show updated date in Google SERP or want users to know when the post was last updated, then this article will help you.

If you are using the GeneratePress theme in WordPress, you might have noticed that there is no option to replace the published date with the last modified date. So, if you want to show an updated date you will have to use a custom code snippet on your website.

You can use the below code snippet in function.php of your theme file. (Make sure you use a child theme, so, it won’t go away after the theme update).

Or you can use a code manager plugin in your website to load the below PHP snippets into your WordPress website.

Steps to Display the Last Updated Date in GeneratePress

To Add a code Manager plugin in WordPress, Go to Plugins > Add New and search for code manager in the search box.

Here, install the WPCode – Insert Header & Footer plugin and you will be able to add PHP code snippets to your website.

Click on the Use Snippet button and you will see a screen like the screenshot below.

Make sure to select the code type for the PHP snippet.

Here is the Php code to show updated or modified date in post.

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

    if ( get_the_date() !== get_the_modified_date() ) {
        $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 );

Use the above code and the last updated date will be added to your GeneratePress theme in WordPress. You can verify this by opening the existing page.

How To Display The Last Updated Date In GeneratePress Theme
How To Display The Last Updated Date In GeneratePress Theme

Edit the page once and update it and you’ll see the publish date has now changed to the last updated date in your GeneratePress theme.

Note: If the post has not been updated previously it will still show the published date as there is no updated date available for it.

You can also verify your website in Schema Validator regarding this. Simply enter the post URL and test your website’s schema. You can see the updated date there.

What is the Benefit of showing the Last Updated date in GeneratePress?

Displaying the last updated date on your website has several benefits:

  • Updated Content: Ensures readers access current information.
  • Higher CTR: Increases click-through rate for your blog.
  • SEO Visibility: Search engines display recent updates in search results.

It also helps in reducing the bounce rate. When users encounter outdated content, they may quickly leave your site, resulting in a higher bounce rate. Keeping your content up to date and displaying the last updated date can help reduce bounce rates by keeping users engaged and satisfied with the information they find.

I hope you have learned how to display last update date on GeneratePress theme in WordPress. If you have any doubts regarding this, let me know in the comments section.

My name is Megha, A computer science student with a passion for digital marketing and SEO, enjoys helping beginners build impressive WordPress websites.