Skip to content

Instantly share code, notes, and snippets.

@manhleo93
Created July 23, 2017 12:19
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 manhleo93/1199879a21e8ed8947b76d44061adb08 to your computer and use it in GitHub Desktop.
Save manhleo93/1199879a21e8ed8947b76d44061adb08 to your computer and use it in GitHub Desktop.
// Display Post Word Count in Genesis
// Note: Special Thanks to Victor Front: Ref: https://www.facebook.com/groups/genesiswp/permalink/1536463436404848/
// 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