Support

Account

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