Home › Forums › Pro Support › Excerpt length – not working
- This topic has 7 replies, 2 voices, and was last updated 2 years, 10 months ago by
elvin.
-
AuthorPosts
-
January 14, 2021 at 8:10 am #25478
Alejandro
ParticipantHi,
I am setting up the plugin as explained in your documentation , but it seems that is not responding as it does not cut the excerpt at 20 words (that is what I setted up).
See my homepage at the bottom.Thank you
January 14, 2021 at 8:51 pm #25502elvin
ModeratorHi,
Are you using manual excerpts? If yes, the entry-summart will use the whole manual excerpt texts you’ve added in instead of using the set excerpt length.
The automatic limit only applies when no manual excerpt is specified.
January 15, 2021 at 9:06 am #25535Alejandro
ParticipantHi Elvin,
Thanks for the explanation.
But I doesn’t have any sense: I am using manual excerpts to control the key message on the post (I replicate it under the title as well). So, could you provide any extra code to patch the plugin? Or may be you plan to update it so far?Best,
Alex
January 17, 2021 at 10:48 pm #25609elvin
ModeratorAh, I think the confusion was from the “excerpt” option not being labeled properly on WPSP.
The excerpt length option works to the automatically created excerpts.
It doesn’t make any sense to limit the manual excerpt because the whole point of having manual excerpt is to let the user have the full/manual control of how many words the user types in as an excerpt. That includes the punctuations and the ellipsis.
Else, let WordPress create excerpts automatically so the limit works.
January 18, 2021 at 2:26 am #25615Alejandro
ParticipantHi,
Thanks for the answer.I am currently using manual excerpts to control what should it be included in the excerpt itself rather to let WordPress pick the initial paragraph to do so.
From this point of view, that does NOT have anything to do on how do I want to show the data around my website.If you access the homepage, it makes a lot of sense to limit the characters shown and on some other parts it is just the opposite.
This is why I am asking to update the plugin or send me the php lines to patch it (I guess it should not be a big deal).
So could you handle this please?
January 18, 2021 at 8:48 pm #25661elvin
ModeratorTry this PHP snippet:
function manual_auto_excerpt($text) { global $post; $raw_excerpt = $text; if ( '' == $text ) { $text = get_the_content(''); $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } $text = strip_tags($text); /*** Change the excerpt words length. If you like. ***/ $excerpt_length = apply_filters('excerpt_length', 30); /*** Change the Excerpt ending. If you like. ***/ $excerpt_end = ' <a href="'. get_permalink($post->ID) . '">' . '» Continue Reading.' . '</a>'; $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); } add_filter('get_the_excerpt', 'manual_auto_excerpt', 5);
This snippet lets the plugin’s excerpt limit to control the manual excerpt as well.
Here’s how to add PHP – https://docs.generatepress.com/article/adding-php/
As for applying it to the official plugin, we’ll see what we can do about it.
January 20, 2021 at 2:37 am #25712Alejandro
ParticipantWorks flawlessly.
Thank you!
Note: In Generatepress you have that option (for the blogroll only) in Customize > Layout > Blog > Content. And is super handy!
January 20, 2021 at 4:35 pm #25740elvin
ModeratorGlad it works for you. No problem. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.