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.
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.