How to Change Number of Related Products Per Row WooCommerce

Change Number of Related Products Per Row WooCommerceDo you want to change the number of related products per row? Related Products is a section on some templates that pulls products from your store that share the same tags or categories as the current product.

It is important to note that the products cannot be specified in the admin. However, it can be influenced by grouping similar products in the same category or by using the same tags.

You may want to increase the number of products on the related products section to develop the browsing or buying choice of the user.

Changing the number of related products to display is very easy. However, you need to have some coding skills to implement this solution.

You can use a plugin, but we recommend using custom code to make minor changes. This is because they add unnecessary bloat to your site.

WooCommerce Change Number of Related Products Per Row

In this post, we will share how you can change the number of related products per row in WooCommerce.

However, you should create a child theme, so that your changes are not lost when an update occurs.

Let us look at how you can achieve this.

Steps to Change Number of Related Products Per Row

This is how the related product section is displayed:related products

Here are the steps you need to follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file where we will add the function that will change the number of related products per row.
  3. Add the following code to the php file:
[php]

function njengah_change_related_products() {

  global $product;

  $args[‘posts_per_page’] = 6;

  return $args;
}

add_filter( ‘woocommerce_output_related_products_args’, ‘njengah_related_products_args’ );

  function njengah_related_products_args( $args ) {

  $args[‘posts_per_page’] = 4; // 4 related products

  $args[‘columns’] = 2; // arranged in 2 columns

  return $args;

}
[/php]

This is the outcome:more products

Conclusion

By now, you should be able to change the number of related products in your WooCommerce store.

You should be careful when editing the functions.php file because if you make any mistake, a critical error will occur.

If you need further customization or if you have any problem implementing the code, please consider hiring a WooCommerce developer.

Similar Articles

  1. WooCommerce Redirect After Checkout : Redirect to Custom Thank You Page
  2. How to Add Checkout Phone Number Validation WooCommerce
  3. WooCommerce Mobile Checkout Optimization Quick Guide

Comments are closed.