WordPress教程:WooCommerce更改相关产品数量

经过 小朱笔记 | 3 月 17, 2019 | WordPress技巧 | 0条评论

更改相关产品数量

/**
 * 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' );

在哪里添加此代码?

将PHP代码放在主题或子主题functions.php文件的底部。

0条评论

提交评论

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理