Tagged: category page, column
Hi,
is it possible to specify the number of columns and the product count only for certain product categories or pages?
thx in advance
max
Hey maxisgoinghome,
If you build custom category pages you’ll be able to specify the columns count.
If you need further assistance please let us know.
Best regards,
Victoria
Hi,
Thank you for the update.
You can use this filter to change the number of products per row in the archive or shop page.
/**
* Change number or products per row to 3
*/
add_filter('loop_shop_columns', 'avf_loop_columns', 999);
if (!function_exists('avf_loop_columns')) {
function avf_loop_columns() {
return 3; // 3 products per row
}
}
Now, if you want to only apply the changes to a specific category, then you have to add conditions inside filter.
/**
* Change number or products per row to 3
*/
add_filter('loop_shop_columns', 'avf_loop_columns', 999, 1);
if (!function_exists('avf_loop_columns')) {
function avf_loop_columns($items) {
if(is_tax('product_cat', 'category_name')) {
$items = 3 ; // 3 products per row
}
return $items;
}
}
Replace “category_name” with the actual name or slug of the product category.
Best regards,
Ismael
Hi Ismael.
thx for the message. Where do I put this code? Quick CSS, function.php or anywhere else?
brg
max
Hi,
You should add the snippet in the functions.php file. And don’t forget to adjust the category name. Let us know if it works.
Best regards,
Ismael
hi ismael,
thx that worked. problem is that the columns don’t get “resized”. I.e. if there is a standard of 5 columns and I decide to add the snippet with 3 columns there is a lot of white space on the right side ;))
thx. you can close the topic.