Reply 356358 to: Shop Page Default views on product categories page, different default views for different categories

Avatar: Rose Tyler
Rose Tyler
Support staff
May 11, 2023 at 12:14

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

Go To The Whole Conversation In Topic
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.