Change the Number of Product Colmun in WooCommerce

In case if you want to display a certain number of product columns on your site, you can easily do that from your template page (content-product.php). You should be able to easily locate this page from “woocommerce/template” folder. Open up the “content-product.php” page with your favorite HTML editor.

Now, locate the following section of the snippet from the page.

<?php
// Store column count for displaying the grid
if (empty($woocommerce_loop['columns'])) {
$woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 4); }
?>

Change the number “4” with your desired number and save the page. Go to the front end section of your site and refresh the product archive page. Surely, you will see your desired number of columns.

Now, if you don’t want to touch the template file, there are even easier way to do this. All you need to do is to copy the following snippet on your theme’s “functions.php” page and update it.

<?php
// change the number of product column
add_filter('loop_shop_columns','ib_custom_loop_columns');
function ib_custom_loop_columns() {
   return 3; }
?>

Just like before, change number 3 with your desired number and you would be good to go. Hope that helps.

Note: Using this snippet will affect your category and subcategory archive page (content-product_cat.php) as well. So, if your intention is to have different number of columns for both the products and category archive post, read this post for better understanding.

Today In History

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.