Forked from renventura/genesis-post-info-with-est-read-time.php
Created
November 26, 2015 16:18
-
-
Save nhatdong/b93347c9009593db7b73 to your computer and use it in GitHub Desktop.
Modified Genesis post info with estimated read time
This file contains hidden or 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) | |
| * Includes estimated read time via the Estimated Post Reading Time plugin | |
| * | |
| * @author Ren Ventura <EngageWP.com> | |
| * @link http://www.engagewp.com/display-updated-date-instead-of-published-date-in-genesis/ | |
| */ | |
| add_filter( 'genesis_post_info', 'rv_post_info_filter_with_est_read_time' ); | |
| function rv_post_info_filter_with_est_read_time( $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> Estimated Reading Time: <span class="estimtaed-read-time">%s</span>', get_the_modified_date( 'Y-m-d' ), get_the_modified_date(), $author_link, do_shortcode( '[est_time]' ) ); | |
| } 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> Estimated Reading Time: <span class="estimtaed-read-time">%s</span>', get_the_date( 'Y-m-d' ), get_the_date(), $author_link, do_shortcode( '[est_time]' ) ); | |
| } | |
| return $post_info; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment