Custom WordPress excerpts

30th July 2015

Reading Time:

On my last few projects I’ve needed to change excerpts throughout the site. To avoid having to do this repeatedly, I’m dropping it here!

The following snippets go in your functions.php file and allow you to define the length of the excerpt, and replace the default ellipsis (¬†‘[…]‘ by default )

// Change Excerpt length */
 function custom_excerpt_length( $length ) {
 return 12;
 add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

// Replace the default ellipsis
 function new_excerpt_more( $more ) {
 return '…';
 add_filter('excerpt_more', 'new_excerpt_more');

Share this post

Leave a Reply

Your email address will not be published.