Display Last Modified Date for Your WordPress Posts Without Plugin

Looking for display last modified date on your WordPress posts without a plugin? Then here we have a solution to do that. Most of the WordPress websites are created with a default post published data on the page. If you have a blog website and updating posts regularly also modifying the posts, then the last modified date helps with the posts. Because that helps users to know when the last modification has been done with content or code in the post.
Let me show you two methods to display the Last Modified Date on your post page.
1. Display with Default get_the_modified_date Function
By using default WordPress get_the_modified_date function, we can display the last modified date of post. Use the below code in your single.php (Single Post) between the title and content.
1 |
<?php printf( __( 'Last modified: %s', 'textdomain' ), get_the_modified_date() ); ?> |
2. Using functions.php Display the Post Modification Date
Add the below code in your functions.php, then the last date and time will append on your above content.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function modified_date( $content ) { $u_time = get_the_time('U'); $u_modified_time = get_the_modified_time('U'); if ($u_modified_time >= $u_time + 86400) { $last_date = get_the_modified_time('F jS, Y'); $last_time = get_the_modified_time('h:i a'); $last_update .= '<p>Last modified '. $last_date . ' at '. $last_time .'</p>'; } $last_update .= $content; return $last_update; } add_filter( 'the_content', 'modified_date' ); |
Conclusion:
I hope this will help you to display the last modified date on your WordPress posts without a plugin. If you have any doubts about this topic let me know in the comment box and if you like this article share it with your friends.
Last Modified DateWithout Pluginwordpress
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]