Support

Account

Home Forums General Issues Filter products/categories/ by ACF field Reply To: Filter products/categories/ by ACF field

  • Ok I think I understand what you are trying to do, but correct my if I’m wrong.

    You want to retrieve TERMS from the taxonomy CATEGORY, but only those terms that have a specific value filled out in a custom field.

    There is an article in the ACF documentation describing how to do this if you were querying posts instead of taxonomy-terms: https://www.advancedcustomfields.com/resources/creating-wp-archive-custom-field-filter/

    However, I believe the same principle can be applied to pre_get_terms (instead of pre_get_posts).
    The filter pre_get_terms is called inside WP_Term_Query so it should work for api requests: https://developer.wordpress.org/reference/classes/wp_term_query/get_terms/