Home › Forums › ACF PRO › Get taxonomy terms from custom loop › Reply To: Get taxonomy terms from custom loop
Hi @juxprose
I believe you need to use the_post() function to get make it work. Could you please try the following code:
$client_args = array (
'post_type' => array( 'clients' ),
);
$query_clients = new WP_Query( $client_args );
if ( $query_clients->have_posts() ) {
while( $query_clients->have_posts() ) { $query_clients->the_post();
$terms = wp_get_object_terms( $post->ID, 'key_tasks' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
echo '<p>' .$term->name. '</p>';
}
}
echo '<pre>';
var_dump( $terms );
echo '</pre>';
}
} else {
// no posts found
}
wp_reset_postdata();
This page should give you more idea about it: https://codex.wordpress.org/Class_Reference/WP_Query.
I hope this helps 🙂
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.