Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show post's published and last updated (if different from published date) in human time in Genesis. Details: http://sridharkatakam.com/using-human-time-last-updated-date-genesis/
<?php
//* Do NOT include the opening php tag
//* Create a shortcode to display published date's human time
add_shortcode('post_date_human', 'set_post_date_human');
function set_post_date_human($atts) {
return human_time_diff( get_the_time('U'), current_time('timestamp') );
}
//* Create a shortcode to display last updated date's human time
add_shortcode('post_updateddate_human', 'set_last_updated_date_human');
function set_last_updated_date_human($atts) {
return human_time_diff( the_modified_date('U','','',false), current_time('timestamp') );
}
//* Customize the entry meta in the entry header (requires HTML5 theme support)
add_filter( 'genesis_post_info', 'sk_post_info_filter' );
function sk_post_info_filter($post_info) {
$post_info = 'Posted [post_date_human] ago by [post_author_posts_link] [post_comments] [post_edit]';
if (get_the_modified_time() != get_the_time()) {
$post_info = $post_info . '<br/>Last updated [post_updateddate_human] ago';
}
return $post_info;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.