Hello,
Because I want to keep my products in a three-column layout on subsequent archives (like category archives) pages, I did not change the Theme Options > WooCommerce settings.
Instead, I added the following CSS for the single-column product categories:
body.shop_archive div.woocommerce ul.products li.product-category { width: 100% !important; } body.shop_archive div.woocommerce ul.products li.product-category a img { max-width: 1200px !important; width: 100% !important; height: 150px !important; object-fit: cover !important; } body.shop_archive div.woocommerce ul.products li.product-category a h2.woocommerce-loop-category__title { margin: 40px; position: absolute; bottom: 0; color: #fff; font-size: 31px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.2rem; } body.shop_archive div.woocommerce ul.products li.product-category a h2.woocommerce-loop-category__title mark.count { display: none !important; }
I added the class shop_archive
to the body by using the following code in my child theme’s functions.php:
/* Add class to body for category archives */
add_filter( 'body_class', 'woo_cat_taxonomy_in_body_class' );
function woo_cat_taxonomy_in_body_class($classes) {
if (is_product_category()) {
// Apply a general class for all product categories
$classes[] = 'product_cat';
} else if (is_shop()) {
$classes[] = 'shop_archive';
}
return $classes;
}
I also found you can change the columns with the following code in functions.php:
/* Change columns displayed per row depending on page types */
add_filter('loop_shop_columns', 'loop_columns', 999);
if(!function_exists('loop_columns')) {
function loop_columns() {
if (is_product_category()) {
return 3;
} else {
return 1;
}
}
}
Hope this code can help someone else. Thank you!