Forums › Forums › Search & Filter Pro › Filtering the default WordPress Search
Tagged: default search, searchwp
- This topic has 23 replies, 2 voices, and was last updated 7 years, 9 months ago by Anonymous.
-
Anonymous(Private) January 26, 2017 at 5:39 pm #85820
Okay, so, I have a normal search results page (using SearchWP/the default WordPress search), and what I’m trying to do is filter those results using Search & Filter.
What’s the best way to go about doing that? I’ve tried various settings but can’t even figure out which “Display Results” setting to use. Nothing I’ve done seems to work. Search and filter lists all information rather than what the search has returned, and when I click on something in S & F the page that loads has the wrong results and doesn’t include the original search.
Is what I’m trying to do even possible…?
Trevor(Private) January 26, 2017 at 7:11 pm #85850Not easily possible. You need to replace the search box in WordPress with a Search & Filter form (even if it is just the textual search box) and use that to get the results. Then the URL query string will be correct for our plugin to use. Many people do this, so you are not alone.
The first step would be to make a simple search and get that working, then figure how to get that into the same place as your theme search box is (usually it is in the header, and you can edit the header.php file, or a file that calls).
Anonymous(Private) January 27, 2017 at 3:50 pm #86090Okay, so based on your advice, I’ve replaced the default search box with a new search & filter form (with just a text search field).
It still gives me the results I want, but this time using Search & Filter rather than the default search.
However…now I have a whole range of new issues. Lol.
I can try and debug the issues I’m having with Relevanssi myself, but the two I can’t figure out, and probably have to do with my forms and settings are:
1. The search page doesn’t refresh when the search box is re-used, even though the url does. It requires a full and proper refresh of the page in order to load the new results.
2. I still can’t get Search & Filter to filter results based on the content of this new page. It’s still treating it as separate, the same as it was for the default form.
The problem I have is that I have to use an archive, because results on the page require formatting and loading of custom fields.
But how do I then filter the results based on the initial search?
Will send over login details in a private reply. Would really appreciate it if you could have a look and tell me what I’ve done wrong.
Trevor(Private) January 27, 2017 at 3:57 pm #86095It will be many minutes before I can look (just going out), but you have to have the text search box in the main form on the results page as well, so that S&F can put the search term into it. Otherwise it won’t stay inside the search results you got. If needed, you can make Custom CSS to make it
display: none !important;
to hide it.Also check if you are using Ajax that the Results container (
#main
by default) is correct. This is covered in the documentation. Otherwise the results will not update until a page refresh is done.Anonymous(Private) January 27, 2017 at 4:17 pm #86106Aha! Super!
So, those two changes seem to work! Updating the main container to content-sidebar-wrap and adding a search bar to the filter form.
Only thing left is to get it syncing with the actual results. At the moment it’s not reading/counting the results and as such is displaying ALL post types etc, as opposed to just the ones we have results for.
That means that if I’m searching for a person then tick the “Jobs” post type I get a “sorry, no results” message.
Any ideas?
Trevor(Private) January 27, 2017 at 4:39 pm #86139With the jobs CPT, that wouldn’t surprise me as there is only one that is published! Be aware that the text search searches only titles and content, and not any taxonomies, categories, tags or custom fields. There IS a way to extend the text search to include any/all of these.
Anonymous(Private) January 27, 2017 at 4:46 pm #86144Yup yup. I’ve done that previously.
My point was – aren’t the empty post types generally hidden?
Jobs shouldn’t be listed in the post types list in the first place, for the vast majority of searches, because none of the results actually have that post type.
Categories also aren’t filtering properly. The count feature seems to be working, and the empty ones are hidden, but when you actually click on one nothing happens. The page reloads but the results stay the same…
Anonymous(Private) January 27, 2017 at 4:57 pm #86157Bugger…that’s annoying. Is there any particular reason for that, or can I add it as a feature request?
As for the categories. If you search something like “Baroness” and then click on one of the categories (any really, but HE/FE and Skills is a good example because you can see that listed as the policy area on a couple of the posts) you’ll see that ALL results are still listed.
It doesn’t actually refine them.
-
AuthorPosts