Site logo

Archived topic

How to customize Search Results template? (to add Relevanssi excerpts)

3 replies · Started by Zach on January 30, 2018

Viewing posts 1–4 of 4

Hi. I'm using the Relevanssi search plugin and I'd like to highlight search terms inside posts after clicking on a search result.

To accomplish this, I need to tweak the search results template so permalinks are generated by a custom relevanssi function. (as described here, after the scrolling bit: https://www.relevanssi.com/knowledge-base/scroll-result-page-search-term/)

I'm having a bit of trouble getting started since GP is so modular: I copied search.php into my child theme, but it uses get_template_part( 'content', 'search' ); to generate the content so it doesn't help. I see the relevant areas in content.php so I think I should make a content-search.php file with my changes included.

I'll need to keep track of any changes to content.php in future GP versions. Is this the most future-proof way to do it?
Thanks -Zach

Hi Zach,

That's exactly correct. Copy content.php and add it to your child theme, then rename it content-search.php.

Then you can make any necessary changes and you'll be good to go.

Let me know if you need more info :)

Great. It worked great. Many thanks for a great theme and great support.

You're welcome! :)

This archived topic is closed to new replies.