Many popular bloggers removed the post date from their articles, This is not a good practice and you should never remove dates from your blog posts. In this tutorial, I will explain the simple & easy code add last updated date on your post in your WordPress site.
In recent changes in Google Search Algorithm, the publish date is also a factor into the search ranking algorithm and it is also visible in SERPs.
Follow the below step to display the last updated date on your WordPress post. Open wp-contents/themes/your-theme/functions.php file and add the below code at the end of the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
//Last updated dates in blog post 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' ); |
After adding the code, visit your post on front-end site, you will see the last updated date & time. See the below screenshot.
Now open your style.css file and add the below code at the end of the file and save it. This code will highlight the last updated date on your post.
1 2 3 4 5 |
.last-updated { background: #b5acac; font-size: small; padding: 5px; } |
After added the above css code, it will look like below screenshot.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: wordpress last modified date, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners, wordpress tutorials, wordpress tutorials for beginners