Woocommerce by default displays 4 categories and products per row in shop page. I want to display 5 categories / products per row, I edited CSS to have 5 columns and to resize the thumbnails, it worked, but the last / 5th column is always empty : the 5th category or product goes to the 2nd line.
If you are using custom theme add this code in your functions.php
// Change number or products per row to 5
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 5; // 5 products per row
}
}
and If you are using any woothemes then add this code in your functions.php
// Override theme default specification for product # per row
function loop_columns() {
return 5; // 5 products per row
}
add_filter('loop_shop_columns', 'loop_columns', 999);
Related
How Can I show more products on my category page instead of the default number of products being shown!? I don't have that functionality in my theme, any hook would help?
I found this, but it's for the shop page.
/*Change the number of products that are displayed per page (shop page)*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 9
return $cols;
I want a solution for the category page?
On the woocommerce shop catalogue page is it possible to have the 'add to cart' button default to six rather than one, but only for a specific category? Selling wine and want it to add 6 bottles at a time, but also selling other items that will be sold individually.
Add this code to functions.php in your theme. Keep in mind that if you update your theme, this edit might be lost. So either save it somewhere to add it again or create a child theme and add it there.
add_filter("woocommerce_quantity_input_args", function($args, $product){
if(!is_cart() && has_term("wine-bottles", "product_cat", $product->get_id())) {
$args['input_value'] = 6;
}
return $args;
}, 10, 2);
Replace "wine-bottles" with the actual name, slug or ID of your category.
This will make the default quantity value be 6 for all products in the specified category on all pages where they're displayed.
im trying to display number of products in shop page (woocommerce) as my requirement but following code seems to not working any more with latest version of WooCommerce
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
}
Looking to have 3 column layout on https://sweetheartshair.com but can not override the 4 column layout
// Change number or products per row to 3
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
code sample is not doing anything - added this to the themes functions.php file as suggested in other samples.
code sample above is correct -> I had it twice in functions file so was conflicting
Please see the photo. Here showing 3 products by default. Here I want to keep 4 products per label. Product container contain more space for per product. I also want to reduce this space for keep more products per label.
How can I keep 4 products per label? Please help me experienced man....
Thanks
Adding this to your functions.php file should work, it should change the 3 products per row to 4 products.
// Change number or products per row to 4
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns'))
{
function loop_columns()
{
return 4; // 4 products per row
}
}