I am currently hard-coding custom taxonomy terms "13329,5555" into a block of code. Instead of hard-coding the custom taxonomy product_cat term_id as "13329,5555" how would I dynamically replace 13329,5555 with (a comma-delimited representation) of only the product_cat term_ids that have their custom field "product_category_customText" populated? In other words I am looking for help replacing 13329,55555 with a variable representing a comma-separated list including only those product_cat terms that have a value (as opposed to blank) in my custom field "product_category_customText" on the product_cat taxonomy.

switch ($taxonomy)
        {
            case 'product_cat': return array(13329,5555); break; 
        }

For what it's worth below is the code that displays the custom field "product_category_customText" when the user is viewing any product_cat:

$queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;

    if( get_field('product_category_customText', $taxonomy . '_'.$term_id)){
        echo '<div id="about_this_category_id">';
        the_field('product_category_customText', $taxonomy . '_' . $term_id);
        echo '</div>';
    }

If someone can please help me replace my hard-coded "13329,5555" with a variable that represents A,Comma,Separated,List of product_cat term IDs where the criteria for building the list is that the product_cat term ids must have the "product_category_customText" field populated, that would be very helpful.

Thank you!

closed as off-topic by Howdy_McGee Dec 28 '16 at 6:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • It appears your question is specific to the ACF plugin. – Milo Dec 27 '16 at 22:59
  • Although I'm using ACF, my question is general. I am seeking help replacing "return array(13329,5555);" with return "array($SomeVariable);" and I am looking for advice in how to define $SomeVariable such that it represents a comma-separated list of only those product_cat (custom taxonomy) term_ids that have a value (as opposed to blank) in my custom ACF field "product_category_customText" on the product_cat taxonomy. – Peter Noges Dec 27 '16 at 23:01
  • It's not general, because ACF has its own implementation of custom fields for taxonomy terms, there is no core method for querying terms using that data. – Milo Dec 27 '16 at 23:04
  • As Milo mentioned, this is an Advanced Custom Fields plugin (ACF) question. As such I have raised this ticket with the ACF support team here support.advancedcustomfields.com/forums/topic/… – Peter Noges Dec 28 '16 at 3:34
up vote 0 down vote accepted

As Milo mentioned, this is an Advanced Custom Fields plugin (ACF) question. As such I have raised this ticket with the ACF support team here https://support.advancedcustomfields.com/forums/topic/how-to-replace-hard-coded-list-of-custom-taxonomy-terms-based-on-custom-field-qu/

Not the answer you're looking for? Browse other questions tagged or ask your own question.