You can use a filter to change the number of words used in automatic excerpts.
Try adding this code either to the functions.php file in a Child Theme or a Functionality Plugin.
function my_custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'my_custom_excerpt_length', 999 );
the return 20 bit limits your excerpts to 20 words – change that number as needed.
Be sure to add this either in a Child Theme or with a plugin like the one I’ve linked to – don’t edit your theme files directly or they changes will likely get overridden when the theme updates!
Dear Chad, can you please explain me how to use this plugin Functionality because I can not find place to put that code, wherever I put and update nothing changes :/ ?
You should be able to click on “Edit Functions” under “Plugins” to access the editor where you paste the code and then click Update File.
It it says ‘Inactive’ at the top (just above where you paste in your snippet) you’ll need to make sure the plugin (and the file it’s creating) are activated.
Open your plugins menu, and look under Inactive Plugins for one that has the same name as your site – make sure it’s activated and you should be good to go.
If that doesn’t work, you may want to contact the plugin author, or try a different functionality plugin, or create a child theme.
Hello Chad,
the excerpt lengt with word is running perfect!
It is possible to fix the length with character numbers?
Thx
Plugin is activated and when I click on Edit Functions it opens my home page. Not showing a place to paste the code :/
@mapohl
The filter is built specifically to limit the excerpt by word count, not characters.
Take a look at this thread – it might help get you going in the right direction 🙂
@nejra993
If you’re still having trouble with that plugin, you can try a different functionality plugin (I linked to one in a previous reply), or you can try setting up a child theme to place the code into.
You can also try a plugin built specifically for excerpts if you’d like:
https://ww.wp.xz.cn/plugins/search.php?type=term&q=excerpt+length