Change no. of related products being displayed on product page in woocommerce? | themelocation

How to change number of related products being displayed on product page in Woocommerce?

Related products are being displayed on a product page on the basis of matching tags among products. By default woocommerce displays two related products.In this tutorial we’ll learn how to increase number of related products on a product page. To do this add some products with a matching tag.

I’ve created seven products with a tag in common i.e. ‘xyz’.

woocommerce

Now go to product page from front end. Initially it will display only two related products:

woocommerce

Now add the following lines of code at the end of your theme’s functions.php file:

function woocommerce_output_related_products() {

                woocommerce_related_products(array('posts_per_page' => 6, 'columns' => 2, 'orderby' => 'rand'));

}

Go to product page again and you’ll see 6 related products.

woocommerce

CHEER SJ

No comments yet.

Leave a Reply