This topic has 2 replies, 2 voices, and was last updated 1 years, 6 months ago ago by Rose Tyler
Hello support team,
Wondering if I can set different default views (list vs grid view) for different categories page?
For example:
I have 2 main categories of products, and sub-categories of each:
—- Vegetables
|——— Broccoli
|——— Cabbage
—- Fruits
|——— Apple
|——— Orange
I would like to have default list view for all vegetable categories pages:
/product-category/vegetables/
/product-category/vegetables/Broccoli/
/product-category/vegetables/Cabbage/
and have grid view for fruits categories pages:
/product-category/fruits/
/product-category/fruits/apple/
/product-category/fruits/oranges/
Is it possible? that would be very helpful for us. Thank you
Hello, Kris,
Thank you for contacting us and for using XStore.
It is possible to customize the child theme by adding the following code to wp-content/themes/xstore-child/functions.php:
add_action('wp', 'et_child_grid_list_query', 2);
function et_child_grid_list_query(){
if( is_product_category( array( 35, 10, 891 ) ) ) {
set_query_var( 'et_view-mode', 'list' );
} elseif( is_product_category( array( 35, 10, 891 ) ) ) {
set_query_var( 'et_view-mode', 'grid' );
}
}
After that, you need to replace the category IDs with the ones you want to use for the respective view. The category IDs can be found in the category editor, as shown in the screenshot: https://prnt.sc/Pn4mA8fEmP8L
Kind Regards,
8theme team
Tagged: categories, default views, shop, themes, woocommerce, wordpress
The issue related to '‘Shop Page Default views on product categories page, different default views for different categories’' has been successfully resolved, and the topic is now closed for further responses