WPCarrot

How to set the excerpt length in WordPress

The default WordPress excerpt length is 55 words. That is quite a lot of text and considering excerpts are intended to be a summary you might want to tame them. The excerpt_length filter will let you set a custom length. add_filter( ‘excerpt_length’, function( $length ) { $length = 32; return $length; }, 12 );

How to change the excerpt more string in WordPress

If an excerpt is greater than 55 words, WordPress will append a more link to the excerpt text. By default the link text is […]. The excerpt_more filter can be used to change this string. add_filter( ‘excerpt_more’, function( $more_string ) { $more_string = __( ‘Continue reading’, ‘text-domain’ ); return $more_string; }, 12 );

How to get a post count on a WordPress site

The wp_count_posts() function will return an object containing a count for each status type. $count = wp_count_posts(); The status types are publish, future, draft, pending, private, trash, auto-draft and inherit. echo $count->publish; // 82 echo $count->future; // 3 echo $count->draft; // 16 echo $count->pending; // 1 echo $count->private; // 0 echo $count->trash; // 25 echo $count->auto-draft; …

How to get a post count on a WordPress site Read More »