In my previous post on using human time for Post Date in Genesis, a couple of readers requested for code snippet that would show when the post was last modified in a similar human friendlier format like the creation date.
Adding the following in child theme's functions.php will show posts' published as well as last updated (if different from creation time) date in a human friendly style. Note that if the post is not yet modified, the modified time is the same as the creation time.
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Hey Sridhar,
Your code is the only one that works out of all the sites I have been to. I was wondering if there was a way to have it say “last updated on” and then the date that it was updated. Does your code notify google that there has been an update? So that date will show up in the search results instead of the published date?
See http://www.sridharkatakam.com/add-last-updated-date-post-info-genesis/
Not as far as I know. We are merely printing the last updated date. Whether Google takes that and shows in search results or not – I do not know.
[…] http://www.sridharkatakam.com/using-human-time-last-updated-date-genesis/#comment-4010 […]
It’s working well for me–thanks for posting! But I’m wondering if it’s possible to have the reverse. That is, if the post has been modified, then the “Posted on” line doesn’t appear.
So that instead of something like:
Posted one week ago
Last updated two days ago
it shows simply as:
Last updated two days ago
I’d prefer ONLY to show the last updated date, with a fallback to the post date if there haven’t been any modifications. I don’t need to show both.
Hi Sridhar,
I’ve implemented the above snippet and it’s working perfectly.
just wondering, Is there a way to make it conditional? Human time as above for single pages
and last modified date example day/month “12 Aug” on category/archive page.
I’ve found this snippet online for the archive date format i’m looking for just not sure how to make them both conditional
Any guidance would be much appreciated.
add_filter( ‘genesis_post_date_shortcode’, ‘child_post_date_shortcode’, 10, 2 );
function child_post_date_shortcode( $output, $atts ) {
return sprintf(
‘%1$s%2$s %3$s’,
$atts[‘label’],
get_the_time( ‘j’ ),
get_the_time( ‘M’ ),
get_the_time( ‘Y-m-d\TH:i:sO’ )
);
}
Many thanks