Skip Navigation

[Resolved] Filter by a taxonomy term custom field

This thread is resolved. Here is a description of the problem and solution.

Problem: Exclude taxonomy terms (categories) and posts from View.

Solution: You can exclude taxonomy terms and posts using wpv_filter_query hook, the code and method is given here: https://toolset.com/forums/topic/exclude-some-taxonomy-terms-from-filter-search/#post-204079

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 2 replies, has 2 voices.

Last updated by Kirill 3 years, 3 months ago.

Assigned support staff: Noman.

Author
Posts
#537102

I have 'Producer' a custom taxonomy and a view that displays goods. This view has a dynamic AJAX filter that allow to filter goods by a certain producer. However, I need to be able to eliminate goods of certain producers from being shown in this catalog.

Let's say I have producers A, B, C, D, and E. I want to eliminate producers B and D, so the users will see only goods of producers A, C, and E when they select 'All producers' in a catalog filter. Users also should see only producers A, C, and E listed in a 'Producers' filter drop-down.

What is the best way to achieve this? I thought of using a custom filed within a taxonomy term, so some taxonomy terms (i.e. some producers) be marked as 'Hidden from catalog'. Then I can show only those terms (producers) that do not have this 'Hidden from catalog' option on. However, Views does not allow me to do that: there is no option to filter by a taxonomy term custom field. Is this not possible currently? What would be the best way to achieve what I need?

Thank you in advance!

Best regards,
Kir

#537147

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Kirill,

Thank you for contacting Toolset Support. You can exclude taxonomy terms and posts using wpv_filter_query hook, the code and method is given here:
https://toolset.com/forums/topic/exclude-some-taxonomy-terms-from-filter-search/#post-204079

Thank you

#537768

This solves my problem. Very cool! Thank you very much.

But please, if you might, consider adding filter by a taxonomy custom fields to Views somewhen in the future. That would be a very valuable addition!

Thanks!

Kir