Relevanssi is a WordPress search plugin which provides a ton of configurable options like showing the search results sorted in the order of relevance, automatic bolding of the search term, ability to exclude and include categories, tags, posts and pages from search.
In this tutorial, we shall create a search template file in Genesis in which we replace the default loop
with a custom one to add support for Relevanssi.
In the custom loop's function, we shall
- get the search term entered by user
- create a WP_Query object in which the above search term and pagination info are passed as arguments
- pass the above WP_Query object to Relevanssi
- run the genesis loop
Screenshot of http://example.com/?s=lorem:
Step 1
Install and activate Relevanssi.
Step 2
Create a file named search.php in your child theme's directory having the following:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
This is great! Is there any way to make it multisite compatible. Relevanssi itself supports cross-searching across subsites, but the catch has always been integrating it with Genesis.
I do not have a multisite set up to test this. Can you give it a try?
Hi – This does not work for me. I am using the standard version of Genesis Sample (not your version).
You can see what happens here: https://superguide.staging.wpengine.com/?s=how+much+super+do+i+need
I am using the latest version of Relevanssi (1.16.0)
I have presumed that I do not include the “<?php” at the top of the code.
Cheers, Rob
That is the problem.
You need to.
Btw, I need to open a Superannuation account. Will study your site.
Thanks Sridhar – And sorry. Silly me. I’ve added back in and it works correctly now.
There are probably lots of issues in our staging site so you are better studying our production website – superguide.com.au (if you didn’t already guess). Good luck. Superannuation can be as complicated as web development.
A couple of other things I wanted to do with Relevanssi was:
a) Have a dedicated search results page so that we could use FacetWP filters on the results page (see http://superguide.staging.wpengine.com/facet-test for example), and
b) When someone searches (using the search box in our header) it loads the results on this page mentioned in a).
Is this the kind of thing that is covered by your Support level membership, or would I need to pay for custom development via genesiscustomizations.com?
Cheers, Rob
The default search results pages (example.com/?s=lorem) will work fine for what you want. Just tested and FacetWP filtering works on the search results powered by Relevanssi.
Make sure you install this plugin: https://facetwp.com/add-ons/relevanssi/