Home › Forums › ACF PRO › check if a certain value exists within query result › Reply To: check if a certain value exists within query result
get_field_object()
used for a taxonomy field will not return the choices. get_field()
only returns the selected choices. The only way that you can get a list of all terms to show the unsollected ones is to use get_terms()
$args = array(
'taxonomy' => 'YOUR TAXONOMY HERE'
);
$terms = get_terms($args);
$selected_terms = get_field('saison', false, false); // get only term IDs
if ($selected_terms) {
foreach ($terms as $term) {
if (in_array($term->term_id), $selected_terms) {
// this one is selected
} else {
// term is not selected
}
}
}
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.