I’m running a wp_query on a page template in order to get posts from a custom post type “tour” filtered by a custom taxonomy “location”. This taxonomy is hierachical and organised “land -> region -> spot”. The current page that uses the template in question has the same taxonomy assigned by an ACF taxonomy field. This wp_query actually works fine:
<?php $args = array( 'post_type' => 'tour', 'location' => 'meran' ); $featured_tour = new WP_Query( $args ); ?>
<?php if ( $featured_tour->have_posts() ) : while ( $featured_tour->have_posts() ) : $featured_tour->the_post(); ?>
<article>
<h1><?php echo get_the_title(); ?></h1>
</article>
<?php endwhile; else : ?>
<p>No tour here! :( </p>
<?php endif; wp_reset_postdata(); ?>
I would now like to replace the name of the location by the term that’s selected in the ACF “spot” field, something like: ‘location’ => ‘function_that_inserts_current_ACF_term’.
Is there any way to retrieve this? Thank you for any advice.
You are now getting the ACF tax field if it exists in your current page.