Skip to content

Instantly share code, notes, and snippets.

@brianleejackson
Last active January 9, 2023 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save brianleejackson/d98aad3831cbe934ddc21e50b08d4e39 to your computer and use it in GitHub Desktop.
Save brianleejackson/d98aad3831cbe934ddc21e50b08d4e39 to your computer and use it in GitHub Desktop.
Display the date a post was updated in the GeneratePress 3.0 theme as seen on https://woorkup.com
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on %2$s</time>';
if ( get_the_date() !== get_the_modified_date() ) {
$time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Updated on %4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
return sprintf( '<span class="posted-on">%s</span> ',
$time_string
);
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment