askdesign
12/28/2016 - 3:59 PM

Display Updated Date Instead of Published Date in Genesis

Updated March 25, 2015 · Ren Ventura

http://sumo.ly/tCin via @CLE_Ren
<?php //* mind this opening php tag

/**
 *	Display Last Updated date if a post has been updated (Genesis Framework)
 */

add_filter( 'genesis_post_info', 'rv_post_info_filter' );
function rv_post_info_filter( $post_info ) {

	global $post;

	if ( 'post' !== get_post_type() )
		return;

	$authorID = $post->post_author;

	$author = get_the_author_meta( 'display_name', $authorID );

	$author_link = sprintf( '<a href="%s"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="entry-author-name" itemprop="name">%s</span></span></a>', get_author_posts_url( $authorID ), $author );

	if ( get_the_date( 'Y-m' ) !== get_the_modified_date( 'Y-m' ) ) { # Modifed date

		$post_info = sprintf( '<i class="fa fa-calendar"></i> Updated: <time class="entry-time" itemprop="dateModified" datetime="%s">%s</time> &nbsp;&nbsp;&nbsp; <i class="fa fa-user"></i> <span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="entry-author-name" itemprop="name">%s</span></span>', get_the_modified_date( 'Y-m-d' ), get_the_modified_date(), $author_link );

	} else { # Published date

		$post_info = sprintf( '<i class="fa fa-calendar"></i> Published: <time class="entry-time" itemprop="datePublished" datetime="%s">%s</time> <i class="fa fa-user"></i> <span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="entry-author-name" itemprop="name">%s</span></span>', get_the_date( 'Y-m-d' ), get_the_date(), $author_link );

	}

	return $post_info;

}