Query Pulling the same post twice

Question

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.

I’ve been told that it’s because the loop is running twice, but i’m not sure how tpo fix that.

0
, , , Addzy 7 months 0 Answers 97 views 0

Leave an answer