Skip to content

Instantly share code, notes, and snippets.

  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save woogists/11472c1f1b4982a83a4f7987d73575ed to your computer and use it in GitHub Desktop.
[Theming Snippets][Change number of products per row for non Woo-developed themes]
/**
* Change number or products per row to 3
*/
add_filter('loop_shop_columns', 'loop_columns', 999);
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
@braddalton
Copy link

braddalton commented Mar 29, 2018

Thanks for this snippet however, based on my testing, you're missing a closing curly bracket. Also, i question your use of !function_exists('loop_columns'). I don't see this as necessary unless you're checking the original function in WooCommerce and its also named loop_columns. Based on my search in woocommerce there is none. Also, i wouldn't use it in that position in the function anyway. I suggest the use of this code https://gist.github.com/woogists/3894598a086c4e265facc16fed0b9c10#file-wc-change-number-of-products-row-wootheme-php

@89gsc
Copy link

89gsc commented May 2, 2018

Missing an end bracket as stated above.

@woogists
Copy link
Author

Updated, thanks!

@aniaq
Copy link

aniaq commented Mar 10, 2020

Thanks for snippet, under which license is it under - GPLv3 like WooCommerce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment