Support

Account

Home Forums General Issues Relationship field in Woocommerce product loop Reply To: Relationship field in Woocommerce product loop

  • Never mind, after posting the question I figured it out and it actually wasn’t difficult at all. See here below:

    
    <ul class="products">
    	<?php
        $ids = get_field('pp_relation', 'option', false, false);
    		$args = array(
    			'post_type' => 'product',
          'post__in' => $ids,
    			'posts_per_page' => 4,
    			'orderby' => 'rand'
    			);
    		$loop = new WP_Query( $args );
    		if ( $loop->have_posts() ) {
    			while ( $loop->have_posts() ) : $loop->the_post();
            wc_get_template_part( 'content', 'product' );
    
            do_action( 'iclicks_related_products_loop' );
    
            echo '</div>';
    			endwhile;
    		}
    		wp_reset_postdata();
    	?>
    </ul><!--/.products-->