Categories

Featured templates

WooCommerce. How to change the number of related products

Ammy Brown July 10, 2015
Rating: 5.0/5. From 2 votes.
Please wait...

This tutorial is going to show you how to change the number of related products in WooCommerce.

WooCommerce. How to change the number of related products

You already know how to set up related products. We will show you how to change number of related products in this tutorial.

WooCommerce._How_to_change_the_quantity_of_related_products

Please, follow steps below to change related products number:

  1. Connect to your server using FTP or hosting Cpanel.

  2. Locate file called shop-functions.php in wp-content/themes/theme#####/includes folder (where ##### is your theme number).

  3. Modify lines 80-97:

    //Related products limit
    function tm_related_products_limit() {
    	global $product;
        $orderby = '';
    	$columns = 4;
    	$related = $product->get_related( 4 );
    	$args = array(
    		'post_type'           => 'product',
    		'no_found_rows'       => 1,
    		'posts_per_page'      => 4,
    		'ignore_sticky_posts' => 1,
    		'orderby'             => $orderby,
    		'post__in'            => $related,
    		'post__not_in'        => array($product->id)
    	);
    	return $args;
    }
    add_filter( 'woocommerce_related_products_args', 'tm_related_products_limit' );
  4. Change $related = $product->get_related( 4 ); number to the number of related products you would like to be shown on your site.

    On the same lines you can change number of columns and order by settings.

Feel free to check the detailed video tutorial below:

WooCommerce. How to change the number of related products
This entry was posted in WooCommerce Tutorials and tagged number, product, Related, WooCommerce. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket