Skip to content

Instantly share code, notes, and snippets.

@Chillifish
Last active July 31, 2018 12:30
Show Gist options
  • Save Chillifish/b35abb24bac80e2181ba4cddb5371c72 to your computer and use it in GitHub Desktop.
Save Chillifish/b35abb24bac80e2181ba4cddb5371c72 to your computer and use it in GitHub Desktop.
Show post date modification
// Get last posted or modified date
function acme_mod_date( $postId ) {
$posted = get_the_time( 'U', $postId );
$modified = get_the_modified_time( 'U', $postId );
if ( $modified >= ( $posted + 7890000 ) ) { // 3 months
return '<time class="updated" datetime="' . get_the_modified_time( 'Y-m-d', $postId ) . '"> Updated on ' . get_the_modified_time( get_option( 'date_format' ), $postId ) . '</time>';
}
else {
return '<time class="published" datetime="' . get_the_time( 'Y-m-d', $postId ) . '"> Posted on ' . get_the_time( get_option( 'date_format' ), $postId ) . '</time>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment