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