Support

Account

Home Forums Backend Issues (wp-admin) Hide taxonomy term in Form and in post Reply To: Hide taxonomy term in Form and in post

  • i have tried this, but it does no work:

    // exclude categories from category dropdown
    add_filter('acf/fields/taxonomy/query/name=materiel_client', 'exclude_categories', 10, 2);
    function exclude_categories( $args, $field ) {
      $terms = get_terms([
        'taxonomy' => 'materiel_client',
        'hide_empty' => false,
    ]);
    
    $excluding = array();
     foreach ($terms as $term)
     {
     // $temp.=get_field ( 'visibilite', $term->term_id  );
     
     if (get_post_meta( $term->term_id , 'visibilite')=='oui'){
     array_push($excluding , get_post_meta( $term->term_id , 'visibilite'));
     }
     }
     
       $args['exclude'] = $excluding; //the IDs of the excluded terms
      return $args;
    }