Home › Forums › General Issues › Query Users from Tax Field (and children) › Reply To: Query Users from Tax Field (and children)
No, setting the field to return the term object does not store the term object in the database. The only thing that ACF stores in the DB is the term ID, no matter what you want to return.
You would need to get the parents of the term and then add them all to your query
$args = array (
'numberposts' => -1,
'order' => 'ASC',
'orderby' => 'display_name'
);
$meta_query = array(
'relation' => 'OR', // this is required, default is AND
array(
'key' => 'department',
'compare' => 'LIKE',
'value' => '"' . $queriedTaxTerm->term_id . '"',
)
);
$ancestors = get_ancestors($queriedTaxTerm->term_id, 'your-taxonomy-slug-here', 'taxonomy');
if ($ancestors) {
foreach ($ancestors as $ancestor) {
$meta_query[] = array(
'key' => 'department',
'compare' => 'LIKE',
'value' => '"' . $ancestor . '"',
);
}
}
$args['meta_query'] = $meta_query;
$wp_user_query = new WP_User_Query($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.