samikeijonen / checathlon

Business type of theme with pixel perfect design
https://foxland.fi/downloads/checathlon/
8 stars 4 forks source link

Less eager update notice #29

Open msaari opened 6 years ago

msaari commented 6 years ago

"Updated on" triggers always when there's an update, because the comparison uses Unix time. This leads to cases of "Posted on 1.1.2018 (Updated on 1.1.2018)", which looks silly.

In checathlon_posted_on() (https://github.com/samikeijonen/checathlon/blob/11e27b4993118b7fa6b44dcafaa763a334b23fa7/inc/template-tags.php) changing this code

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>'; }

to this:

if ( get_the_time( 'Y-m-d' ) !== get_the_modified_time( 'Y-m-d' ) ) { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; }

would solve the issue. Since the date is displayed on day level, that's accurate enough for the comparison.