Change WordPress’s Excerpt Length

The default excerpt length of WordPress is 55 words. Some one like me may want to change the excerpt length.

I like the have a smaller excerpt length for the homepage. WordPress provides a interface for changing the default excerpt length. The method is very simple and easy.

Put these codes into the function.php file in the theme directory. I prefer 35 in my blog. It can be changed to any number you like. Or this value can be stored in the options table.

The code:

// excerpt length
function option_excerpt_length($text){
  return 35;
}

add_filter('excerpt_length', 'option_excerpt_length');
  •  
  •  
  •  
  •  
  •  
  •  
  •  
The following two tabs change content below.
Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

One Reply to “Change WordPress’s Excerpt Length”

Leave a Reply

Your email address will not be published. Required fields are marked *