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!
Our guide looks into WordPress custom fields and how they stack up against the possibilities of ACF.
— Advanced Custom Fields (@wp_acf) July 18, 2022
https://t.co/hk3yibkHyk
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.