Tagged: columns productcategorys
-
AuthorPosts
-
November 18, 2023 at 11:38 pm #1425952
Hi there,
i would like to set the colmuns per product category in some product categories.In Woocommerce I can only change the global setting, which is then for all product categories on the entire site.
Is there a way to set the columns only per product category?
Or is this not possible via the theme and I have to search on Woocommerce?
Best regards
ChristianNovember 19, 2023 at 12:24 am #1425954Hey Chrisxx1982,
How many columns do you want them to be? If you want them to be 2 columns try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:add_filter('loop_shop_columns', 'loop_columns', 999); function loop_columns() { return is_product_category(array(34, 35)) ? 2 : 3; }
and change the category IDs to suit, then add this css:
.shop_columns_3 .products.columns-2 .product { margin: 0 1% 1% 0; width: 48.6%; }
If you want them to be 4 try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:
add_filter('loop_shop_columns', 'loop_columns', 999); function loop_columns() { return is_product_category(array(34, 35)) ? 4 : 3; }
again change the category IDs to suit, then add this css:
.shop_columns_3 .products.columns-4 .product { margin: 0 1% 1% 0; width: 23.6%; }
Only use one or the other, not both.
Best regards,
MikeNovember 19, 2023 at 1:01 am #1425955Hi Mike,
thanks alot. I’ll try it out and report back if it worked.
I have never entered PHP code anywhere :) Do you know where I can find it, is it in the theme settings? So also a field similar to quick css?
I would like to set the colums to 4 in a few product categories. Currently global is set on page 3.
Best regards
ChristianNovember 19, 2023 at 1:20 am #1425956Hi Mike,
I tried it and it works :) That’s really great that you can do something like that too.
Thank you very much, that helps me a lot. I first increased the page width and removed the sidebar for some product categories, but then the product boxes at 3 columns are too big. For this reason I now need 4 columns for some product categories.
Great, I’m very happy about the fast support. You have helped me a lot so far, thank you very much.
Best regards
ChristianNovember 19, 2023 at 2:20 pm #1425972Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Columns in Productcategorys’ is closed to new replies.