Support

Account

Home Forums General Issues Use ACF taxonomy to Query Reply To: Use ACF taxonomy to Query

  • Possibly something like:

    <?php
    $testMe = get_field('store_the_genre'); //assume this is returning a term ID?
    
    global $wp_query;
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array(
        'post_type' => 'store',
    	'posts_per_page' => 11,
    	'paged' => $paged,
        'tax_query' => array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'style',
                'field'    => 'slug',
                'terms'    => $style,
            ),
            array( 
                'taxonomy' => 'store_the_genre',
                'field'    => 'term_id',
                'terms'    => $testMe,
            ),
    	
        ),
        'meta_query' => array(
            'relation' => 'AND',
            array(
                'key' => 'store_city',           
                'value'    => $villeshow,
    			'compare'    => 'IN',
            ),
    	
        ),
    );
    $query = new WP_Query( $args );		
     
    if( $query->have_posts() ) :
    	while( $query->have_posts() ): $query->the_post(); ?>
    	<p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>	</p>
    	<?php endwhile;
    	wp_reset_postdata();
    else :
    	echo 'No stores found';
    endif;

    It depends if your store_the_genre taxonomy is a single value/multi value and returning the ID?