Home › Forums › General Issues › Get taxonomy name from 'Taxonomy' field and insert into custom loop as category? › Reply To: Get taxonomy name from 'Taxonomy' field and insert into custom loop as category?
Yes, that makes more sense. If I’m understanding correctly then the changes to the query that I posted should be working. Maybe it has something to do with using the global $wp_query variable, you shouldn’t be doing that.
also, just to be sure, did you change your taxonomy here
to the slug for your custom taxonomy and $term_id
to the term ID that you want to return?
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array (
'post_type' => 'exercise-database',
'tax_query' => array(
array(
'taxonomy' => 'your taxonomy here',
'terms' => array($term_id),
'operator' => 'IN'
)
),
'pagination' => true,
'paged' => $paged,
'order' => 'DESC',
);
$my_query = new WP_Query( $args );
if ($mny_query->have_posts()) {
while ($wp_query->have_posts()) {
$wp_query->the_post();
?><h2><?php the_title(); ?></h2><?php
} // end while
wp_reset_postdata();
} // end if
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.