Maybe the following a dumb question, I apologise in advance.
We have an archive page and want to add a custom search to the sidebar of that page.
We add the WP Views Filter to the sidebar, then need to select a 'Target page to show the results'.
That content type archive page is a page, not an archive.
Do we need to create a view on that page to display the results?
Do I understand it correctly we are leaving the archive in that case? It is not a search filer on the archive itself but a custom view?
When I select an option in the custom search in the sidebar, the spinner is running, but the results in the archive are not changing and there is also no redirect to this custom view.
You have pretty much understood that correctly, yes, you are talking about adding search controls from a View to an archive, and the two are similar but not the same.
Ideally if you are on an archive page you want to use the archive (because WordPress will run an archive query in any case, even if you don't output any results from it).
You know that you can include custom search in an archive?
Normally this will output at the top, before the results, and you want the search form to be at the side.
The way to do that is using CSS.
If you are using the newer block editor to design your custom archive then that's handled for you, you can add a column block with two columns and move the search into a narrow column and the results into a wide column, for example. (It's a bit fiddly moving blocks around like this, but I've done it and it works.)
If you are using the classic editor for Views then you would need to add some markup and CSS to output the search and results in columns.
Go to the Screen Options tab at the very top of the page and make sure that the Output Editor is checked so that the section is visible at the bottom of the page.
This editor contains two shortcodes, wpv-filter-meta-html which outputs the search filter controls section, and wpv-layout-meta-html which outputs the results. You can add some markup to split these into columns as desired (using an existing grid system like Bootstrap if it is active on your site, or using some simple CSS of your own).
Thanks so much, that's brilliant. It's so obvious, but we never thought about that option. It has been a good choice to go ahead with Blocks.
I read in the support forums that the spinner is not yet available in Blocks, right? No problem, we can add that later.
Is it possible to add a search field in which we can have in 'in between' custom fields values expression, e.g. like a number in between value 0-1000 (min-max), like it can be done in Views?
I just tried adding a custom search filter for a numeric field to an archive using a between comparison while using Blocks and found that I could (screenshot).
Thanks a lot, that solves part of the mystery:
The difference is in 'Type of control' because I selected the check boxes option. In that case the options in 'Using this comparison' are only 'In' or 'Not in" (I included a screenshot).
What we would like to achieve - in an ideal world of course 🙂 - is a set of checkboxes and 'Using manual entered values' to capture the values in a series of classes, like 0-499, 500-1000, etc. I managed to do this in Views, but not (yet) in Blocks.
I'm having trouble visualising how that would work before thinking about how to do the same with Blocks.
The between comparison inserts two filter controls, one for the lower bound, one for the upper, and you are achieving this with one filter control for a range.
The topic ‘[Closed] Search view in sidebar’ is closed to new replies.