X
X

Display the post date or “Today” in an archive

Display the post date. Only output the date if the current post’s date is different from the previous one output (like the_date).

Use the_date for yesterday or older.
Use “Today” for today, but only for the first post of the day (same behaviour as the_date).

<?php 
$latest_query = new WP_query( $args );
...
//inside the loop:
$today = date('Y-m-d'); 
$published_date = get_the_date( 'Y-m-d' ); 
if ( $published_date < $today ) { the_date(); } elseif ( $published_date == $today && $latest_query->current_post == 0) { echo 'Today'; } ?>