- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
WooCommerce. How to change the number of related products
July 10, 2015
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 productsYou already know how to set up related products. We will show you how to change number of related products in this tutorial.
Please, follow steps below to change related products number:
Connect to your server using FTP or hosting Cpanel.
-
Locate file called shop-functions.php in wp-content/themes/theme#####/includes folder (where ##### is your theme number).
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' );
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