Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter addzydev

    (@addzydev)

    I solved it:

    Just in case anybody ever has any trouble querying a post with the same term of a Taxonomy in another Post Type. I’ll post my answer below because I finally solved it on my own.

    `<?php

    $terms = get_the_terms( $post->ID, ‘supplier-tax’);
    foreach ( $terms as $term ) {
    $termID[] = $term->term_id;
    }

    $the_query = new WP_Query( array(
    ‘post_type’ => ‘supplier’,
    ‘tax_query’ => array(
    ‘taxonomy’ => ‘supplier-tax’,
    ‘field’ => ‘slug’,
    ‘terms’ => ‘$termID’,
    ),
    ) );

    while ( $the_query->have_posts() ) : $the_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_postdata(); ?>`

    I hope this helps someone because this was hard to find a solution too.

Viewing 1 replies (of 1 total)