Skip Navigation

[Resolved] Search/filter for nested view where parent is based on taxonomy

This support ticket is created 3 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by philippeS-4 3 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#2046437

HI there,

I am building a basic Glossary where I am using a taxonomy for the Alphabet.

On the webpage below I use a basic view based on the posts where I am using the taxonomy to filter and also a search function.
hidden link

Now on this page I use a nested parent/child views where the parent is based on the Alphabet taxonomy this work great and I get the look desired where the post are grouped based on the taxonomy. My issue is I am not sure how to implement on this page the same filtering and search function as on the other page. On the parent view it says "Only Views listing posts can have custom search inputs."
hidden link

Not sure if this is possible, if yes how? Do you have any example? Or maybe the taxonomy is not the right approach for this?
Thanks,
Phil

#2046963

My issue is I am not sure how to implement on this page the same filtering and search function as on the other page. On the parent view it says "Only Views listing posts can have custom search inputs."
Okay I understand you would like to filter the view of posts by text search and by taxonomy term (from an alphabetical grouping taxonomy), but that View of posts is nested inside another taxonomy View for grouping purposes. Unfortunately there is no simple solution in this scenario, because, as the message explains, it is not possible to add front-end filtering to taxonomy Views or User Views. Only Views showing posts of some kind support front-end custom search filters. Furthermore, if you add front-end filtering controls to the inner nested View, by default you will produce a list of results grouped alphabetically, with search filters repeated in each grouped set of results. That is not really ideal for what you want to achieve.

You could try a workaround here, but it's not really intended to use Views this way so I cannot guarantee it will work exactly as expected. I think it will be worth the effort to test, though. You could try adding custom search filters to the View of posts, then try displaying the filters separately from the results of that View. We offer shortcodes for displaying the filters and results independently. Use the following shortcode syntax to display only the results part of the nested View, not the filters, nested inside the loop of your existing taxonomy View:

[wpv-view name="your-nested-view-slug" view_display="layout"]

Replace your-nested-view-slug with the slug or name of the post View. Add any other shortcode attributes here from your current View setup, if needed for filtering or other purposes. To display the search filters section independently, use the wpv-form-view shortcode instead with this format:

[wpv-form-view name="your-nested-view-slug" target_id="self"]

Again, replace your-nested-view-slug. You should not add any other shortcode arguments.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-1496531

The limitations I expect, and you should be aware of:
- AJAX updates are not supported for either View. Searching and filtering must trigger full page reloads, and your View must update the URL to include URL parameters when searching.
- Pagination is not well supported in this scenario. If you add pagination to the inner View for example, pagination will appear for each group of results. If you add pagination to the outer View, the number of posts per page will not be predictable because you're actually paginating based on the term groups, not based on the posts.
- You may need to adjust the outer taxonomy View's Query Filter to respond to the same URL parameter used by the inner View's Query Filter. Otherwise you may see empty term groups after filtering.

#2047603

Thanks Christian,

The fact of using [wpv-view name="your-nested-view-slug" view_display="layout"] for the nested view meant it wasn't using the parent filter for the taxonomy and basically showed all the posts under each entry.

The filtering wasn't working, so I just used an anchor link for each taxonomy. Not perfect but it is good enough!

Cheers,
Phil