Created
June 6, 2019 09:22
-
-
Save WordBits/6104a2828c6352998fdd442d0e44229e to your computer and use it in GitHub Desktop.
This code was borrowed from WP Beginner's website: https://www.wpbeginner.com/wp-tutorials/display-the-last-updated-date-of-your-posts-in-wordpress/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/display-the-last-updated-date-of-posts/ | |
// Created by: Liam Dempsey | |
?> | |
<?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' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment