Home › Forums › ACF PRO › How To list categories based on Taxnomy meta value › Reply To: How To list categories based on Taxnomy meta value
Hi @vicky8394
Just to clarify for future readers:
You are using the taxonomy ‘category’ with a custom field (taxonomy) to select multiple ‘brands’, where ‘brand’ is a taxonomy type.
You care now trying to query the DB for all categories which contain a brand value.
The problem here is that WP does not offer a termeta table (like postmeta) and doesn’t offer any functions to query terms via a custom field.
ACF saves term custom field values into the wp_options table which makes it very hard to query.
Unfortunately, you can’t join the tables together due to the way the data is saved, and you will need to consider 1 of these 2 options:
1. Change your ‘category’ from a taxonomy to a post_type. This will allow for much simpler querying
2. Load all categories, and then loop over them, load the ACF data for each (get_field) and use PHP to compare the data. This is not very efficient but will work
Thanks
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.