Vukommers has plug-ins Related products, but they select products by categories and tags, but there is no plug-in that selects by an arbitrary field, is there such a function in woocommerce?
- There is no such function. You can look at the code Related products and make your sample on the base. Nothing particularly complicated. - KAGG Design
|
1 answer
Can you please tell me how to make Related products in an arbitrary field, otherwise my knowledge is already over !?
In this code I tried a bunch of varics maybe it's not here?
if ( ! defined( 'ABSPATH' ) ) { exit; } if ($ related_products):?>
<section class="related products"> <h2><?php esc_html_e( 'Related products', 'woocommerce' ); ?></h2> <?php woocommerce_product_loop_start(); ?> <?php foreach ( $related_products as $related_product ) : ?> <?php $post_object = get_post( $related_product->get_id() ); setup_postdata( $GLOBALS['post'] =& $post_object ); wc_get_template_part( 'content', 'product' ); ?> <?php endforeach; ?> <?php woocommerce_product_loop_end(); ?> </section> |