Add this code in functions.php (replace “20” with the desired number of words):
/* Set the maximum number of words in a post excerpt */ function mytheme_custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'mytheme_custom_excerpt_length', 999 );
Source: https://developer.wordpress.org/reference/hooks/excerpt_length/