Hi. I am trying to create a banner for single posts and have the hook below (from one of the site-library sites). How do I show the updated date?
<h1>
{{post_title}}
</h1>
<p>
{{post_author}} | {{post_date}} | {{post_terms.category}}
</p>
If it helps, here is the code I use sitewide to display the updated date. I tried to add shortcode to it but apparently the header hook has no option to activate shortcodes.
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%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 );