Created
March 27, 2019 14:10
-
-
Save deeman/931aefc0b7caff836a9e028ea6cbe3ff to your computer and use it in GitHub Desktop.
Genesis Framework - Display Word Count for Posts
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
| //* WORD COUNT IN POSTS | |
| add_shortcode( 'word_count', 'word_count' ); | |
| function word_count() { | |
| return sprintf( __( '%s words', 'text-domain' ), str_word_count( strip_tags( get_post_field( 'post_content', get_the_ID() ) ), 0 ) ); | |
| } | |
| add_filter( 'genesis_post_info', 'custom_post_info_filter' ); | |
| function custom_post_info_filter( $post_info ) { | |
| if ( is_singular( 'post' ) ) { | |
| $post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit] [word_count]'; | |
| } | |
| return $post_info; | |
| } | |
| add_shortcode( 'word_count', 'word_count' ); | |
| function word_count() { | |
| return sprintf( __( '%s words', 'text-domain' ), str_word_count( strip_tags( get_post_field( 'post_content', get_the_ID() ) ), 0 ) ); | |
| } | |
| add_filter( 'genesis_post_info', 'custom_post_info_filter' ); | |
| function custom_post_info_filter( $post_info ) { | |
| if ( is_singular( 'post' ) ) { | |
| $post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit] [word_count]'; | |
| } | |
| return $post_info; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment