How to show Last Updated Date on a post?
-
Hi –
I’ve placed the PHP code in my functions.php file to show the Last Updated Date on all posts.
It works – but I’d like to find out if it’s possible to have the Last Updated Date information show up on the same line as the author’s name at the top of a post instead of where it currently sits? (For all posts – not just the one attached to the url I provided.) I’d like the new date to be immediately visible to a visitor – and I can’t seem to get the Last Updated Date to show up in a Google Search – so I’m trying to get it up higher on the page for those people who do open the post.
I’m using the Virtue Child theme.
Here’s the code I added to functions.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’ );I’m not sure if this code needs “tweaking” or if there is something I am overlooking in the theme options. I’d love some advice ??
Thank you!
Meagan
The page I need help with: [log in to see the link]
- The topic ‘How to show Last Updated Date on a post?’ is closed to new replies.