Change Excerpt Length in WordPress

This simple code goes inside the functions.php

// Custom excerpt length
function custom_excerpt_length( $length ) {
    return 50;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );