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’.

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

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