Thanks for the reference. I tried the following:
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
if (!is_product_category('target-category-here')) {
function loop_columns() {
return 2;
}
}
}
and
add_filter('loop_shop_columns', 'loop_columns');
if (!is_product_category('audio')) {
function loop_columns() {
return 2;
}
}
Neither had any effect. The category pages don’t change the number of columns at all. This problem is a bit of a head-scratcher. Some categories have only two subcategories, so I didn’t want them to be arranged in four columns per row as that would leave two empty spaces. Blowing up those two subcategories to take up the entire area of two columns would be better than the current set-up.
Some categories need to display 3 columns, others 4 and 2 etc. So I would be targetting specific categories with each block of conditionals. I couldn’t create an array as coding isn’t my strength (I’ve seen them used in different ways before).
I appreciate any guidance to get this solved!