I’m trying to make category page to show 7 columns , but it modifies subcategories too. Is there any way to modify only the main category page without applying it to subcategories?
https://www.prospecs.lt/?post_type=product
my code :
add_filter('loop_shop_columns', 'loop_columns', 999);
if (!function_exists('loop_columns')) {
function loop_columns() {
return 7; // 3 products per row
}
}
3
Answers
You can apply the condition and separated the templates for the category and subcategory page.
You can check if it the current page is a
subcategory
with this function.You can then use it in your if statement
Note that in your code, the main filter argument is missing for your function. Now you can use the following to define the main product category loop columns:
Code goes in functions.php file of the active child theme (or active theme). Tested and works.