• Resolved spinksys

    (@spinksys)


    How do I limit the excerpt length in search results? Is that something I do within the plugin, or in my theme?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Are you referring to the display of the results? Similar to how you can change whether or not to display a full post content, or just a part of the post before linking to the individual post permalink? And also how you can change the length of the excerpt with a touch of code?

    Thread Starter spinksys

    (@spinksys)

    Sorry for the confusion!

    For example, right now my search results look like this (this is a different site btw):

    How to Quickly Customize Unsplash Pictures
    … marketing hipsters, Shutterstock to every kind of marketer, designer, creator. It would be interesting to survey Unsplash users about the reasons why they use it: I expect most would just …

    Posting Trends on Four Different Facebook Pages
    … to get more in touch with their customers online. Therefore they often create prize competitions, surveys and DIY ideas. Beside that, IKEA occasionally provides you with background information about the …

    Collect Analytics and user feedback with Hotjar
    … Each survey is also reachable via a direct URL which you could link to. The survey component is maybe not as powerful as surveymonkey or typeform. But it’s powerful …

    Startups at Uprise Festival 2015: Learn platforms, Tents out of cardboard, Spotify of Gaming and Tinder of Job search
    … appointments, sending newsletters, a newsfeed, you can post files, chat with other group members, create surveys etc. The platform is targeting professional training institutes offering in-person trainings looking for …

    So it goes linked title, then long excerpt for each returned post/page. I want the excerpt to be roughly half as big. Say, 30 words instead of 55 words. But I can’t figure out how to get that to work with WP Search with Algolia.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I don’t presently have a way to test this, but I’m legit wondering if the proper process here would be to customize the excerpt length before it gets indexed or perhaps use the excerpt metabox to control the excerpt as a whole. Then the rest would be customizing the templates to use the excerpt, in case it’s not already, from the returned objects from an Algolia query.

    Is that making sense overall?

    Thread Starter spinksys

    (@spinksys)

    Yes, I think so.

    First of all, I don’t have a great (or good!) understanding of how the excerpts are generated. They are being pulled dynamically, right? When I search, autocomplete is changing the text in the excerpt. My assumption is that as I search for a term the excerpt is automagically created with the search term in it (to give the excerpt context).

    While it would be super easy to use js/php to cut down the numbers of words displayed, I am concerned that I would lose that context. That’s why I assumed there was some easy way to programatically changed the default excerpt size.

    And so, back to your answer. It seems like customizing the excerpt length before index seems like the best solution, but I’m not sure how to do that. Any thoughts on where I might look?

    Thanks for all your help!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    It really depends on how much excerpt generation Algolia search is doing on its own, or if it’s just relying on indexed data from WP.

    On the WordPress side, there’s the excerpt metabox where you can type in a quick summary length value, and it’s stored in the post_excerpt column for the wp_posts table. Then, whenever the theme calls functions like the_excerpt(), it pulls that column value and displays that. If there are cases where that column is not used and filled in, then it will create one from the post_content column.

    Via PHP filters, you can amend the length of the excerpt as demo’d at https://developer.www.ads-software.com/reference/hooks/excerpt_length/

    When it comes to the algolia side, I think the post content and post excerpt data points my be getting indexed as properties on each respective posts objects, and thus it may be possible via the templates, to choose which property gets displayed with that output. This is at least the case with a site that I know my parent company WebDevStudios has done that uses Algolia search. I was able to see post_excerpt on returned results while typing in a query.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Limit excerpt lenth’ is closed to new replies.