Skip Navigation

[Closed] View query filter AND dropdown filter

This support ticket is created 3 years, 12 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.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 3 years, 12 months ago.

Author
Posts
#2189943

Tell us what you are trying to do?

I want to create a view that is limited to specific categories while also allowing the user to filter by those categories but it seems you can't do both? Is there a way around this?

For example I want a view that shows me post type - resources, and only resources tagged with custom taxonomy - whitepapers, reports, videos, e-books (while ignoring all other categories in this taxonomy).

Easy enough to set this up so far.

But now I also want users to be able select with a dropdown from those four categories as they please.

It seems you can't both set a filter query and a selector for the user to filter these?

#2189995

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

That's right.

When you set a query filter it applies permanently, on every page load, where you specify—in this case—the terms that should be applied to the query.

When you add a front-end filter, it is also using a similar query filter, but instead of you manually specifying the terms in the View settings, the terms are passed from the front-end filter via a URL parameter.

You either set the terms manually in the settings, or the front end user sets the terms.

What you can do is use the API, specifically the wpv_filter_taxonomy_query hook, to modify the View arguments.

You would check whether the URL parameter for the front-end filter has some value, and if not (e.g. when first loading the page), set the taxonomy terms that you want to otherwise enforce.

See https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_query

The topic ‘[Closed] View query filter AND dropdown filter’ is closed to new replies.