Tell us what you are trying to do?
I have multiple CPTs, most of which have many-to-many relationships. There are also 2 custom taxonomies applied to a couple of the CPTs.
I am attempting to have one 'master' set of search (mainly title) and filter (mainly taxonomy) controls, followed by outputs of matching posts from each post type. The idea is to have a set of controls on a homepage, followed by a few separate views which each output a list of posts from one CPT (for instance, 12 loaded by post title, ascending, in a Bootstrap grid with a 'load more' under each view), so that the user can either browse and expand any of the separate views, or apply a filter and/or search at the top of the page to see only the matching filtered results in each of the views below.
So:
Search: [search and filter]
CPT1: [grid of items]
CPT2: [grid of items]
CPT3: [grid of items]
Etc.
Thanks (and apologies) in advance - I'm absolutely sure I'm missing something, but I cannot work out how how to do this. I'm sure I need to use nested views (and I've been reading and following those docs), but I just get endlessly repeating lists of results whatever I try.
Hi,
Thank you for contacting us and I'd be happy to assist.
Originally, the views search feature is designed to work with only a single list of results, so what you're planning will require some workaround.
Here are the steps:
1. Please create a post view for anyone of the CPTs ( e.g. CPT1 ) and include the common search filters.
2. Create a duplicate of that view for each CPT and in the post-selection, change the post type accordingly.
3. Now on the page where you'd like to show the common search form, insert the shortcode for the first view, which only shows the search form, without the results.
Example:
[wpv-form-view name="view-to-show-post-cpt1" target_id="self"]
Note: You'll replace "view-to-show-post-cpt1" with the actual slug of your view.
4. Below that form, you can include the shortcode for each of these views, so that only the results and not the search form, are shown:
Example:
[wpv-view name="view-to-show-post-cpt1" view_display="layout"]
[wpv-view name="view-to-show-post-cpt2" view_display="layout"]
[wpv-view name="view-to-show-post-cpt3" view_display="layout"]
Important note: This workaround will only work if the involved views are set to update the search results on page reload and not through AJAX.
Once the search form will be submitted, it will update the results for all the views, because the search filters will be the same.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hi Waqar,
Thanks very much for this - I knew there must be a workaround. I'll have a go at this and come back to you.
Thanks again,
James
You're very welcome James.
Please let me know if you need any further assistance around this and for a new question/concern, please open a new ticket.
regards,
Waqar