How to set the excerpt length in WordPress

The default WordPress excerpt length is 55 words. That is quite a lot of text and considering excerpts are intended to be a summary you might want to tame them. The excerpt_length filter will let you set a custom length.
add_filter( 'excerpt_length', function( $length ) {
    $length = 32;
    return $length;
}, 12 );