For more information, see Display last updated date on articles
/**
* Published & Modified Date Shortcode
*
* @link https://www.billerickson.net/code/published-modified-date-shortcode
*
*/
function be_published_modified_date_shortcode() {
$date = get_the_date( 'U' );
$updated = get_the_modified_date( 'U' );
$output = '<span class="entry-date"><span class="label">Published on</span> ' . get_the_date( 'F j, Y' ) . '</span>';
if( $updated > ( $date + WEEK_IN_SECONDS ) )
$output .= ' <span class="entry-date-modified"><span class="label">Updated on</span> ' . get_the_modified_date( 'F j, Y' ) . '</span>';
return $output;
}
add_shortcode( 'be_published_modified_date', 'be_published_modified_date_shortcode' );