set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
-
I am trying to make the WooCommerce shop page display 3 products per row in the main loop only not in any other products widgets on the shop page, I want those widgets to show 4 products per row
I am using the following filter to do so
add_filter( 'loop_shop_columns', function( $columns ) { return is_shop() ? 3 : 4; }, 10, 1 );
What is happening is that since
is_shop
returnstrue
if it’s the shop page the main shop loop and all widgets on the shop page are being affected and showing 3 products per row instead of 4, I need a way to check if the current loop is the main shop loop to change the number of columns to be 3 or 4 otherwise
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise’ is closed to new replies.