WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been looking for an answer for a couple of days now. I've tried every snippet possible, changing the functions files, creating a separate template for content products but I can't change the number of products listed. Currently WooCommerce displays 4 products per row. Adding a css class of "last" to that fourth product. I want to display the products in a line of three products.

Here is the url to the current store: http://teamhappiness.org/store/

share|improve this question

You didn't say what snippets you've actually tried, but according to the docs, you can filter loop_shop_columns like so:

function wpa65503_woo_shop_columns( $columns ) {
    return 3;
add_filter( 'loop_shop_columns', 'wpa65503_woo_shop_columns' );

tested and working for me with Twenty Eleven theme.

EDIT - this is the particular line in the default content-product.php template file that makes the above filter work. you could just set it directly if you're using a custom template file and don't need it filterable:

// Store column count for displaying the grid
if ( empty( $woocommerce_loop['columns'] ) )
    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );
share|improve this answer
Just added that code but it still displays 4 columns. – Martin Hasan Sep 18 '12 at 18:35
where did you add it? in your theme's functions.php? if it still displays 4 columns then there's something elsewhere in your theme setting number of columns. – Milo Sep 18 '12 at 18:42
I changed it on the theme's funtions.php and I've created a template file for content-product.php – Martin Hasan Sep 18 '12 at 19:47
Does your template file apply the filter? see edit above. – Milo Sep 18 '12 at 22:33
Yeah, same thing. There has to be something overwriting it... – Martin Hasan Sep 18 '12 at 22:42

Hey guys I was searching around the same issue; just found the solution! It's not involving content-product.php at all (at least in my case), it's involving the file woocommerce > single-product > related.php Make a template of this file (if you don't know how to override WooCommerce template study that) and find this code:

$args = apply_filters('woocommerce_related_products_args', array(
'post_type'             => 'product',
'ignore_sticky_posts'   => 1,
'no_found_rows'         => 1,
'posts_per_page'        => $posts_per_page,
'orderby'               => $orderby,
'post__in'              => $related
) );

All you've got to do is change the variable


In which number of related products you want to display! For example:

'posts_per_page'        => 10,

Will display 10 products.

share|improve this answer
Be aware that this solution may require you to change the file again after you update WooCommerce. – fischi Dec 27 '12 at 10:41
No need to copy the template file for this change. See that woocommerce_related_products_args filter at the top? That's where you need to hook into to override posts_per_page. – Geert Dec 27 '12 at 10:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.