0
WooCommerce提供documentation关于如何更改产品页面上显示的相关产品的数量。有没有办法改变他们如何与相关?看来他们目前正在按类别进行关联。有没有基于单一属性显示相关产品的方法?如何按属性显示相关产品 - WooCommerce
筛选下方:
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Change number of related products on product page
* Set your own value for 'posts_per_page'
*
*/
function woo_related_products_limit() {
global $product;
$args = array(
'post_type' => 'product',
'no_found_rows' => 1,
'posts_per_page' => 6,
'ignore_sticky_posts' => 1,
'orderby' => $orderby,
'post__in' => $related,
'post__not_in' => array($product->id)
);
return $args;
}
add_filter('woocommerce_related_products_args', 'woo_related_products_limit');