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. Required fields are marked *

About the author

Rik Kendell is a developer, designer and writer in Leeds, UK, specialising in responsive WordPress websites. With over 10 years experience in the industry, Rik has worked on award-winning teams at agencies, in-house and as a freelancer. Rik has worked with clients ranging from the NHS, Sky and Skipton Building Society to McDonalds, Lamb’s Navy Rum and Crabbie’s Ginger Beer.

Outside of work Rik is also a keen writer, an amateur woodworker, gamer and foodie. His blog posts, reviews and Tweets have been published by the BBC, the Evening Standard, the Guardian and the Independent. He has written guest posts for a number of agencies and industry websites.