Change Excerpt Length In WordPress

Need to change the default excerpt length in WordPress to make it longer or shorter. All you may need is to add a function to your WordPress theme’s functions.php file.

Adding custom excerpt lengths to WordPress

To change the default excerpt length in WordPress, you need to add a function to your WordPress theme’s functions.php file.

  1. Navigate to Appearance > Editor > Theme Functions from your WordPress Dashboard;
  2. Copy and paste the code below;
  3. Click Update File to save the changes.
function custom_excerptlength( $length ) {
 return 20;
}


add_filter( 'excerpt_length', 'custom_excerptlength' );