Support

Account

Home Forums General Issues Echo Taxonomy field IDs to WP Query Reply To: Echo Taxonomy field IDs to WP Query

  • Assuming the $cats is receiving values it seems like you’ll want to update the code to:

    
    <?php
    $cats = get_field('rel_posts_cat');
    $my_query = new WP_Query(array(
    	'showposts' => '10',
    	'category__and' => $cats, 
    ));
    while ( $my_query->have_posts() ) : $my_query->the_post();
    ?>
    

    The change is on the 'category__and' parameter, since $cats should be returning an array assuming you’ve defined the Return Value to Term ID