Custom Excerpt Lengths
This support request was posted in Flatbase by DShrev2
- DShrev2 September 21, 2017 at 5:18 pm
I am looking to customize the displayed excerpt on the Search Results page (I’d like to make it bigger, ~140 words).
I’ve tried plugins designed for this (Relevanssi, Read More Excerpt, etc.) but none seem to influence the size of the excerpt.
I think perhaps this is because the search.php file is pulling nice_excerpt rather than the_excerpt, which is what the plugins seem designed to customize.
Is there anything I can do or anything I can add to functions.php in order to get a larger display excerpt on the Search Results page?
Juanfra Aldasoro September 21, 2017 at 6:30 pmHi,
Thanks for writing. I hope you are doing well.
Unfortunately, at this moment there’s no code you can include in your functions.php to limit that. The solution for this particular case, would be using a child theme and override the search.php template with a new one including the function the_excerpt() instead of nice_excerpt().
Best,
JuanJuanfra Aldasoro September 23, 2017 at 2:29 pmHi,
Thank you for the follow-up.
My pleasure 🙂 I’m always happy to help.
Have a nice day,
Juan.DShrev2 September 26, 2017 at 7:55 pmHi, Juanfra–
I wanted to follow up on this before starting.
If I just replace “nice_excerpt” with “the_excerpt” in a search.php within the child theme, this should make the change necessary to configure the length of the displayed excerpt?
Juanfra Aldasoro September 26, 2017 at 8:38 pmHi,
Thanks for the follow-up.
Actually by doing that modification, you will be using the WordPress native excerpts, and they will be displayed in full. If you want to limit the number of chars you can send a parameter to nice_exerpt.
Like for example:
nice_excerpt(400);
Will limit the number of chars to 400.
Best,
Juan.
You must be logged in to reply to this topic.