Skip to content

Instantly share code, notes, and snippets.

Created June 29, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f003adfd0c49413226aae76a2390c92e to your computer and use it in GitHub Desktop.
Save anonymous/f003adfd0c49413226aae76a2390c92e to your computer and use it in GitHub Desktop.
Displaying the Updated date using Genesis Framework
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment