To a little give more context: all the posts have an “Except” field filled out on the Edit Post settings.
> When the except field is filled out, the max length does not work.
> If I remove the excerpt text and let wp display the article “as the excerpt” then the max length works – but this is undesirable for SEO as a lot of times we have our own Excerpt
Plugin Support
Elvin
(@ejcabquina)
Hi there,
> When the except field is filled out, the max length does not work.
The max length won’t work for Manual excerpt because the manual excerpt is meant to display ALL the words added to it’s field. That’s the purpose of having manual excerpt.
But if you must trim even the manual excerpt, you can use this PHP snippet:
https://wpshowposts.com/support/topic/excerpt-length-not-working/#post-25661
Trimming it like this should work as well:
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
wp_trim_words( $excerpt, 2, '...' ),
get_permalink(),
__( 'Read more', 'generatepress' )
);
}
return $output;
}
Change 2 in wp_trim_words( $excerpt, 2, '...' ), to the word limit.