Created
April 16, 2019 23:41
-
-
Save eksiscloud/5b4516813612c53d3a0be4d559b2ed6f to your computer and use it in GitHub Desktop.
Wordpress, shows last modified date before the content
This file contains 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
function my_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 entry-meta"><b>Last updated on '. $updated_date . ' at '. $updated_time .'</b></p>'; | |
} | |
$custom_content .= $content; | |
return $custom_content; | |
} | |
add_filter( 'the_content', 'my_last_updated_date' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment