Archived topic
Change post lenght
5 replies · Started by albabes on July 29, 2022
I'm using this code below in the popular plugin, "Code Snippets". I'm using the "Run snippet everywhere" option.
I want my posts to show fewer words than the default 55 words. But its not working. https://dbsatucson.org
Ideas anyone?
function my_excerpt_length($length){
return 40;
}
add_filter(‘excerpt_length’, ‘my_excerpt_length’);
Hi there,
you can adjust the excerpt length in Customizer > Layout > Blog
Thanks David. So is that "very common code" just not compatible with GP? I read it doesn't work on TWENTY themes either?
Hi there,
For more info about this filter, check here: https://developer.wordpress.org/reference/hooks/excerpt_length/
Make sure you have a high priority set.
Thanks David and Ying
For a specific example see here:
https://docs.generatepress.com/article/excerpt_length/
Notice we add a really high priority.
:)