Support

Account

Home Forums General Issues How to replace hard-coded list of custom taxonomy terms based on custom field qu Reply To: How to replace hard-coded list of custom taxonomy terms based on custom field qu

  • Are you using ACF5?

    If you are then you can use get_terms() with a meta_query https://developer.wordpress.org/reference/functions/get_terms/

    
    <?php 
      
      $args = array(
        'taxonomy' => 'product_cat',
        'meta_query' => array(
          array(
            'key' => 'product_category_customText',
            'value' => '',
            'compare' => '!='
          )
        )
      );
      $terms = get_terms($args);
      
    ?>
    

    If you are using ACF4, then it will be more complicated. ACF4 has not been updated to use term meta. In this case you’d need to get all the terms and then loop through them all to see if they have a value in the field.