We understand this is annoying. But without advertising-income, we can't keep making this site awesome for you.
Please disable your adblock and script blockers to view this page. Appreciate! 🙏
Home English Articles How to Display Last Updated Date Posts In WordPress (Stepbystep)

How to Display Last Updated Date Posts In WordPress (Stepbystep)

by MAL CHIA
Display Last Updated Date Posts In WordPress last modified maomao maomaochia

How to Display Last Updated Date Posts In WordPress is not a fresh questions on google. But if you are a blogger that regularly update your site content, this might be your answer to helps in your blogger journey. We may found some blog posts showing the last updated date or modified date on their posts but some may not. Everyone want to read a latest post instead of a 5 years old posts. So showing the last updated date/ last modified date is signification important. However, I’ve found that many articles of this topic on google have reveal an outdated information that may not work properly or bug occurs, this is why this article published. In this article, i will show you how to display the last updated date posts in WordPress the completely step-by-step guide in 2018.

Display Last Updated Date Posts In WordPress last modified maomao maomaochia

Why You have to Display Last Updated Date Posts In WordPress?

Most of the website show blog posts on the last publish date, it’s absolutely no problems with that. However, for regular blogger it’s important to noted that display last updated date posts will indirectly affect your entire blog growing. Some article also shown that the benefits of show last modified date. One example is it affect your google ranking because google likes latest updates more than old posts. Since, google know latest updates carry latest information than old posts so it will eventually rank up your publication. So, how to do it? Let’s get started.

 

Method 1: Change Published Date to Last Updated Date

This tutorial required to add code in your WordPress files, if you don’t know how to do, you can find this guide. Because now a day many themes use their own tags, so for methods one we have to find the date tag in order to change it, However, i will step by step teach you how to do.

 

Video Tutorial

Continues reading for step-by-step instructions.

Steps 1: Open Google Chromes Inspect.

On your keyboard press F12 to open inspect.

Display Last Updated Date Posts In WordPress last modified maomao maomaochia

Steps 2: Find the code.

After click on the small icon, move your mouse cursor to the posts date and left click. Now you can see the code of the date, don’t do anything on it just recognize it. Normally remember CLASS=”XXX”.

Display Last Updated Date Posts In WordPress last modified maomao maomaochia

Steps 3: Find the located php file.

Now go to your [Appareace] > [Editor] > [“YourWpTheme”]. Find the code that you have recognize on the previous steps. Found “the_time( get_option(‘date_format’))“. *Here to noted that not every theme located at the same file,. However, you can try to find it on single.php or archive.php. In this case, my themes was located on content-single.php.

How to Display Last Updated Date Posts In WordPress

 

Steps 4: Go to file manager on Cpanel.

You can’t directly edit those code in WordPress editor, otherwise you will get a fatal error. Go to file manager, find your php file (this case is: content-single.php) and download one copy in case anything happen.

The path will be the host or in [../public_html/”YourWordpressFileName”/wp-content/themes/”YourThemesName”]
Display Last Updated Date Posts In WordPress last modified maomao maomaochia

 

Steps 5: Edit the php file.

Display Last Updated Date Posts In WordPress last modified maomao maomaochia After backup right-click edit the file, go in you will see the code. Change the original date_format code and click save.

Here have 3 options to display last updated date.

Options 1: Change the publish date to display the last updated date.

<?php
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 864) {
echo "<p>Last modified on ";
the_modified_time('F jS, Y');
echo " at ";
the_modified_time();
echo "</p> "; }
?>

Options 2: Display the last updated date or may display the publish date if not available.

<?php
if (get_the_modified_time() < get_the_time()) : ?>
 <?php echo "<span>Last modified on ";
 the_modified_time('F jS, Y');
 echo "</span>"; ?>
 <?php else:
 echo "<span>";
 the_time('F jS, Y');
 echo "</span> "; ?><?php endif;
?>

Display Last Updated Date Posts In WordPress last modified maomao maomaochia

Options 3: Display the last modified date and publish date.

Just paste it right at the bottom of your themes function.php file.

function wpb_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('F jS, Y');
$updated_time = get_the_modified_time('h:i a');
$custom_content .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
}
 $custom_content .= $content;
 return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );

 

Steps 6: Done! Successful display last updated date posts.

Now open your WordPress blog posts and check, successful display last updated date posts.

Display Last Updated Date Posts In WordPress last modified maomao maomaochia

Additional Css

You may want the date showing in your style, you can adding css class to make it suit for your blog.

Display Last Updated Date Posts In WordPress last modified maomao maomaochia

And the final results will be like this.

Display Last Updated Date Posts In WordPress last modified maomao maomaochia

 

Method 2: Show Last Updated Date Before Post Content

For this second methods, this is easier just to copy the code and paste it to the themes function.php file. Follow the steps 4 on above to go to your themes function.php. No matter what’s writing in the functions.php files just paste the code to the bottom at the last.

Path: wp-content/themes/[theThemesName]/function.php

function wpb_last_updated_date( $content ) {
$u_time = get_the_time('U'); 
$u_modified_time = get_the_modified_time('U'); 
if ($u_modified_time >= $u_time + 86400) { 
$updated_date = get_the_modified_time('F jS, Y');
$updated_time = get_the_modified_time('h:i a'); 
$custom_content .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>'; 
} 

$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );

Show Last Updated Date Before Post Content-min

 

Conclusion

Displaying last updated in place of published date helps you in many aspects of blogging. It’s helped for you and your readers. However it annoy but that’s fine. I hope this tutorial can solve your problems, if any part isn’t clear enough please feel free to let me know.

You may need to improve your site.

Welcome to MAOMAO Blog, and thank you for reading this post.
If you have any questions please comments below or find me on social media.
I really like to hear from you. #SEE MY WORKS

Leave a Comment

You may also like