wordpress last updated

Do you regularly update your articles? Do you want to show the last updated date on your WordPress posts & pages? Here is the solution.

Many of the readers ask me about the common problem they are facing. The problem is that the most of the WordPress posts and pages bear the published date but not the WordPress last updated date. Many of such websites use the WordPress that regularly updates the old articles. For them, WordPress last updated date is an important information. But unfortunately, WordPress themes bear only the last published date.

Secondly, Google searches also regard a 2-year old published date with suspicion. To go around this problem, one needs to update the content regularly and the last updated date too.

But WordPress won’t display that the content has been updated by default. So, this article will show that how to deal with the problem of WordPress last updated date.

 

How to implement WordPress “modified_date”?

To add WordPress “modified_date” you don’t have to do much. You just have to replace some code with the code snippet given below. For example, if you are working on Twenty-Seventeen theme of WordPress;

  • Just go to Theme Folder within WordPress Installation folder.
  • Move to Template-tags.php file and locate the twentyseventeen_time_link function.
  • Find the old code.
if ( get_the_time() !== get_the_modified_time() )
{
$time_string = '<time class="entry-date up_post published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
$post_status='Updated on ';
}
else
{
$time_string='<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated pubpost" datetime="%3$s">%4$s</time>';
$post_status='Posted on ';

}

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

// Wrap the time string in a link, and preface it with ‘Posted on’ or ‘Updated On’.

return sprintf(__( '<span class="screen-reader-text">%s</span><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">%s</a>', 'Domain_name' ),$post_status,$time_string );
  • Replace this code with the new code given below
if ( get_the_time() !== get_the_modified_time() )
{
$time_string = '<time class="entry-date up_post published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
$post_status='Updated on ';
}
else
{
$time_string='<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated pubpost" datetime="%3$s">%4$s</time>';
$post_status='Posted on ';

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

// Wrap the time string in a link, and preface it with ‘Posted on’ or ‘Updated On’.

return sprintf(__( '<span class="screen-reader-text">%s</span><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">%s</a>', 'Templatetoaster' ),$post_status,$time_string );

You are done. Now you can see the last updated date on your post.

 

Final Thoughts

Displaying the WordPress last updated date can have a great impact on your site. You just have to paste the little snippet for this. The viewers will believe more in updated content. This will pay you a lot in terms of better rankings, more views, and more user engagement. You do lots of things to improve the conversion rate, decrease the bounce rate and time-spent by users on your sites. These efforts just serve as a bonanza with a beautifully-crafted site. So, to create an amazing website, get your hands on TemplateToaster, a WordPress Theme Builder that can generate a theme in less time with advanced tools magically.