After seeking help and failing, I managed to write a query for Wordpress that does exactly what it's suppose to do, however it pulls the post that it's suppose to in twice. I've stared and stared at the markup and I can't see why it's doing it. Here's the query:
<?php $the_query = new WP_Query( array( 'post_type' => 'product', 'tax_query' => array( 'taxonomy' => 'supplier-tax', ), ) ); while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php $terms = get_the_terms( $post->ID, 'supplier-tax'); foreach ( $terms as $term ) { $termID[] = $term->term_id; } $my_query = new WP_Query( array( 'post_type' => 'supplier', 'tax_query' => array( 'field' => 'slug', 'terms' => '$termID', ), ) ); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <p class="supplier">Supplied by <strong><?php the_title(); ?></strong></p> <img src="<?php the_field('logo'); ?>"> <?php endwhile; ?> <?php wp_reset_query(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> If anybody could help, or point out where I'm going wrong so that i can learn from it, I'd really appreciate it.
however it pulls the post that it's suppose to in twice.?supplierwheresupplier-taxtaxonomy linked with ? is it ?termin thesupplier-taxtaxonomy. I need to pull the post that shares the same term into the other post's page.supplier-taxplease confirm ?