Support

Account

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