Get 10% Discount On GeneratePress Premium Theme Avail Now

How To Display Last Updated Date In GeneratePress Theme 2020?

In this post, you will learn how to display Last updated date in GeneratePress Theme.Your readers will stay more on your website, if you show last updated date .

  • Save

If you are using GeneratePress premium theme then you can easily tweak some CSS code and PHP.

It is always good practice to show updated date to your readers.

Because, people want to read latest and updated content. So that’s why we have written this post “How to display Last updated date in GeneratePress”.

Why We Show Last Updated Date In GeneratePress Theme

From SEO point of view, it is very important to make your readers display last updated date in your WordPress site using GeneratePress theme.

If you have written a post months ago and now you have updated it with latest information added to it.

Also Read : How to host Google fonts locally in GeneratePress

By doing so, you are inviting Search engines like Google, Bing to rank your posts on priority basis.

By default, WordPress only allows to show the published date on each of your posts.

But it is not a good SEO practice.

So whenever you update an old posts, your post must display last updated post.

And we have provided you the best way to show last updated post in generatepress theme.

Displaying Last Updated Date In GeneratePress With Plugin

If you are not comfortable with CSS and any kind of complex coding, then it is better to do it with plugins specially designed for such task.

So in order to show last updated date in WordPress using GeneratePress theme, you can use one of the best plugin to play with PHP and other coding right into your WordPress theme.

And the name of the plugin is Code snippets.

Code snippets plugin
  • Save

The best thing about this plugin is that you need not to mess with the complex files with your theme.

Now go to Plugins > Add new > Code Snippets.

Install the plugin and activate it.

Recommended : Remove URL field from comment form

Next, go to snippets > Add New > Give its title name, so that you can easily recognize it for any editing.

Now copy the following Code and paste it in the above newly created snippets.

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

Save and Activate it.

The final result will show “published On” , if the post is newly published.

See result :

Display last published date
  • Save

And if the post is updated it will show “Last Updated On” with date.

Look at below shot :

Display last updated date
  • Save

Display Last Updated Date In GeneratePress Without Plugin

If you want to show last updated date without any plugin, then can add the following CSS.

Firstly, if you are using GeneratePress premium theme, then you are good to go.

Go to Appearance > Customize > Additional CSS

Put the following CSS code in the blank space.

.posted-on .updated { display: inline-block; 
} 
.posted-on .published { display: none;
 }
.posted-on .updated:before {
    content: "Last updated: ";
}

In the above code, if you want to change the words ” last updated ” with any of your choice, you can simply change it.

Final Words

Finally, we have explained the process to how to display last updated date in GeneratePress theme.

If you have learnt something here, do share it.

Also :

Check rich snippets Test in Google

Display last updated date in generatepress
  • Save

I am Kuldeep Singh a teacher by profession and blogger by great passion. You can learn here blogging related tips and tricks.

Leave a Comment

Share via
Copy link