Support

Account

Home Forums General Issues get categories with advanced cutsom field Reply To: get categories with advanced cutsom field

  • there is an error in my code

    
    <?php 
      
      $args = array(
        'taxonomy' => 'category',
        'hide_empty' => 0
      );
      $c = get_categories($args);
      $c_keep = array();
      foreach($c as  $cat){
        if (get_field('isprofession', 'category_'.$cat->term_id)) {
          $c_keep[] = $cat; // forgot [] here
        }
      }
      
      foreach($c_keep as $cat){
        echo $cat->name;
      }
      
    ?>