My code is based on the underscores reference theme.
I have a posted_on
function as follows:
function example_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%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() )
);
$posted_on = sprintf(
' %s',
$time_string
);
echo '<span class="posted-on">' . $posted_on . '</span>'; //WPCS: XSS OK.
}
The result is that example_posted_on()
correctly displays only the published date.
My questions are: Why does it get the modified date anyway?
How is it possible to show the modified date in addition or instead the published date.