To limit the excerpt to 20 words in WordPress, you can use the `wp_trim_words` function. Here's how to do it:
// Get the excerpt with a limit of 20 words
$excerpt = get_the_excerpt();
$trimmed_excerpt = wp_trim_words($excerpt, 20);
echo $trimmed_excerpt;
This code retrieves the excerpt of the current post and then trims it to 20 words before displaying it. You can use this snippet in your theme files where you want to show the excerpt.