search ]

Change the Default Excerpt Length in WordPress

The following filter lets you set the excerpt length that WordPress displays when calling the the_excerpt function. In this example we set the excerpt length to 20 characters only:

function new_excerpt_length($length) {
     return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

This uses the excerpt_length filter. Learn more in WordPress Hooks Explained.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo