Last active
February 13, 2020 23:11
-
-
Save renventura/26f87154d76cf7d60448 to your computer and use it in GitHub Desktop.
Display the Date a Post Was Updated in the Genesis Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> <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