Published & Modified Date Shortcode

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' );
Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk