Hey
I saw in an old post a snipper of php that changed the element header to show Published on, updated On.
Works a treat, the only side effect is now all my posts have the created date as the first line of the body – how can I remove/hide that
function db_modified_time_stamp( $output, $time_string ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on %2$s</time> ';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">Updated on %4$s</time> ' . $time_string;
}
// get modified time and published time. Compare the two, If modified date exists then ouput both time strings with modified date
$updated_time = get_the_modified_time( 'U' );
$published_time = get_the_time( 'U' ) + 86400;
if ( $updated_time > $published_time ) {
$time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified" style="display:inline;">Updated on %4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date('F j, Y') ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date('F j, Y') )
);
return sprintf( '<span class="posted-on">%1$s</span>', // WPCS: XSS ok, sanitization ok.
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
)
);
}
add_shortcode( 'hero_date','db_modified_time_stamp' );
https://share.getcloudapp.com/DOu2EZNA