Last active
July 31, 2018 12:30
-
-
Save Chillifish/b35abb24bac80e2181ba4cddb5371c72 to your computer and use it in GitHub Desktop.
Show post date modification
This file contains hidden or 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
// 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