Nov 7, 2013 - eCommerce, Wordpress    Comments Off on WooCommerce change number of Related Products to show

WooCommerce change number of Related Products to show

To change the number of related products only you can use this code in the Theme Functions (functions.php) file:

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

 

Note: This change may be overwritten by a Theme update.