Display Word Count in Post Info in Genesis
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
// Display Post Word Count in Genesis | |
// Note: Special Thanks to Victor Front: Ref: https://www.facebook.com/groups/genesiswp/permalink/1536463436404848/ | |
// And Sridhar: https://sridharkatakam.com/display-word-count-posts-genesis/ | |
// Print Post Word Count and Create a Shortcode | |
add_shortcode( 'word-count', 'post_word_count' ); | |
function post_word_count() { | |
return sprintf( __( '%s Words', 'leaguewp' ), str_word_count( strip_tags( get_post_field( 'post_content', get_the_ID() ) ), 0 ) ); | |
} | |
// Customize Post Info in Entry Header and Insert Short Code for Post Word Count | |
add_filter( 'genesis_post_info', 'post_info_filter' ); | |
function post_info_filter( $post_info ) { | |
if ( is_front_page() || is_archive() ) : | |
$post_info = '[post_date][word-count][post_comments]'; | |
return $post_info; | |
elseif (is_single()) : | |
$post_info = 'By [post_author_posts_link] on [post_date][word-count][post_comments]'; | |
return $post_info; | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment