Answer the question
In order to leave comments, you need to log in
get_terms not working with ACF?
Hello everyone, I've been trying to figure out for a week what the problem is not working get_terms does not work with ACF, here is the code
$locations = get_terms(array(
'taxonomy' => 'locations',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'display_on_page',
'value' => true,
'compare' => '='
)
)
));
function acf_update_term_meta($value, $post_id, $field) {
$term_id = intval(filter_var($post_id, FILTER_SANITIZE_NUMBER_INT));
if($term_id > 0)
update_term_meta($term_id, $field['name'], $value);
return $value;
}
add_filter('acf/update_value/name=storemeta_state', 'acf_update_term_meta', 10, 3);
add_filter('acf/update_value/name=storemeta_city', 'acf_update_term_meta', 10, 3);
function acf_load_term_meta($value, $post_id, $field) {
$term_id = intval(filter_var($post_id, FILTER_SANITIZE_NUMBER_INT));
if($term_id > 0)
$value = get_term_meta($term_id, $field['name'], true);
return $value;
}
add_filter('acf/load_value/name=storemeta_state', 'acf_load_term_meta', 10, 3);
add_filter('acf/load_value/name=storemeta_city', 'acf_load_term_meta', 10, 3);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question