Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
WooCommerce - change number of products displayed per 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;

Thanks, worked beautifully! Used to display 12 (instead of 24) items on a page instead of the usual 10 (leaving two empty)

were do I add this to? thanks again

EDIT* got it theme function.php

danriti commented Aug 11, 2012


yoxalld commented Aug 15, 2012

Is there a way to change this on the fly? I want to add a button to view all items on the main shop page. Thanks!


ghost commented Nov 9, 2012

Great! But it doesn't work if you add a new taxonomy to the product and you want to get more products.

jorgeSr commented Dec 10, 2012

Great !

jjbbrr commented Apr 3, 2013

Used exactly as presented here and it worked perfectly (using Wordpress 3.5.1 and Woocommerce 2.0.5)

core2kx commented Apr 10, 2013

Fantastic solution! Thank you very much. WP 3.5.1 WC 2.0.5 Works perfectly.

Юзаю тему Sommerce. Захожу в редактор,выбираем тему, потом functions.php
Добавляем в конце эту строчку и вуа ля:

Thanks :)!


wteja commented Sep 1, 2013

That great ! Thanks.

Thank you.... Worked like a charm!

I know i'm not the sharpest tool in the shed, but why go through all this to add more products to the page, when this is controlled by WP through settings/reading, where you just set the post count ?

If it says 10, then you will get 10 products displayed on your shop page, setting it to 12, gets you 12 a.s.o. :)

All the best

I'm new to PHP and I'm curious what the "20" is for in the snippet above?

Boblebad... I tried to change it the way you described and it didn't work for me so I had to use the snippet. I think that function is "Theme" sensitive but the

Um... so under which heading in Woocommerce functions.php does this line of code go? Under;

function woocommerce_legacy_paypal_ipn() {
function woocommerce_template_redirect() {
function woocommerce_nav_menu_items( $items, $args ) {
function woocommerce_nav_menu_item_classes( $menu_items, $args ) {
function woocommerce_list_pages( $pages ){
function woocommerce_update_cart_action() {
function woocommerce_add_to_cart_action( $url = false ) {
function woocommerce_add_to_cart_message( $product_id ) {
function woocommerce_clear_cart_after_payment() {
function woocommerce_checkout_action() {
function woocommerce_pay_action() {
function woocommerce_process_login() {
function woocommerce_process_registration() {
function woocommerce_order_again() {
function woocommerce_cancel_order() {
function woocommerce_download_product() {
function woocommerce_readfile_chunked( $file, $retbytes = true ) {
function woocommerce_ecommerce_tracking_piwik( $order_id ) {
function woocommerce_products_rss_feed() {
function woocommerce_add_comment_rating( $comment_id ) {
function woocommerce_check_comment_rating( $comment_data ) {
function woocommerce_get_order_id_by_order_key( $order_key ) {
function woocommerce_track_product_view() {
function woocommerce_layered_nav_init( ) {
function woocommerce_layered_nav_query( $filtered_posts ) {
function woocommerce_price_filter_init() {
function woocommerce_price_filter($filtered_posts) {
function woocommerce_save_password() {
function woocommerce_save_address() {
function wc_get_product_terms( $product_id, $taxonomy, $args = array() ) {
function _wc_get_product_terms_parent_usort_callback( $a, $b ) {

I'm no expert, but I believe you should include the code in your own theme/childtheme functions.php file. That way, when you update woocommerce, you won't overwrite your custom edits. The same goes for your theme. If you are using a theme you didn't create, then create a childtheme and include the code in your childtheme's function.php file. Hope this helps!

You can change this dynamically without editing code using WordPress:-

Go to yourdomainname/wp-admin/options-reading.php

The is the reading settings then Blog pages show at most ??

The default is 10.

You can edit this value to the required amount. 12 puts the amount on the page nicely.

The column count:-


// Store column count for displaying the grid
if ( empty( $woocommerce_loop['columns'] ) )
$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );

The number here is the total number of products in each line.

I suggest you to update this code according to 2014 ^^.

add_filter( 'loop_shop_per_page', function ( $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.
    return 9;
}, 20 );

works 100% - thx.

Great suggestion by chameleonwebservices. You don't need to mess around with Woocommerce files, just go into Options and change the reading settings to show any number you want. Default is usually set at 10. So if you want to show 20 products per listing, change 10 to 20. Note that this may or may not work depending on your setup or theme. But it worked with me. Thank you chameleon, thanks everyone.

Is there a way to make a product taxonomy (a product category page) show more than the default 5 per page? This code doesn't work for that.

In my site during page load it displays 4 products in a row but after the page gets completely loaded it displays only 3 products. I have tried all above solutions but no success. Can anyone help me out?

I too am looking to change the number of products displayed on the category page. I could write it myself, if I could just find where it is. Is there a category page template?

BTW, why is it "5"? Seems so random and such a small number and that doesn't work for a layout of 3 or 4 per row.

Works like a charm (WP 4.0, WC 2.2.3). Cheers!

Fredbnm commented Nov 14, 2014 thank man, you really helped me

Awesome, thanks! Worked perfectly

i want my products to be displayed as per this website ,
I have made changes in my theme's archive-product page, but not able to get as code for the archive page is

ID, "product_cat");?>
        <div class="page-content">      

            <?php if ( have_posts() ) : ?>

            <div class="product-image">

                <?php woocommerce_product_loop_start(); ?>

                <?php woocommerce_product_subcategories(); ?>

                <?php while ( have_posts() ) : the_post(); ?>

                <?php wc_get_template_part( 'content', 'product' ); ?>

                <?php endwhile; // end of the loop. ?>

                <?php woocommerce_product_loop_end(); ?>


                     * woocommerce_after_shop_loop hook
                     * @hooked woocommerce_pagination - 10
                    do_action( 'woocommerce_after_shop_loop' );


                    <?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>

                    <?php wc_get_template( 'loop/no-products-found.php' ); ?>

                    <?php endif; ?>

esucces commented Sep 7, 2015

I have set my shop page to show 12 products, works like a charm. But my search result page show only 10 products - is there a simular snippet I can use for the search result page?

jnz31 commented Sep 23, 2015

this is a dynamic variant, if you want to have multiple values / let the user decide, how many articles should be shown. all you need is a variable called "show" in your url ( f.ex. will display 99 ).
if there is no variable, it will default to 9. or change the 9 at the end of the return statement..

add_filter( 'loop_shop_per_page', function ( $cols ) { return isset( $_GET['show'] ) ? wc_clean( $_GET['show'] ) : 9; }, 20 );

now all you need to do is add some buttons that set the variable "show" to your theme..

s2ar commented Oct 3, 2015


I registered my account to say thank you, thank you very much for saving my time its works perfectly.

Just added in this page

A lot of my time is saved and boggling my mind i was screwed up but its so easy.. its in settings > Reading Settings > just change the page show at most to 12 where it was 10 by default..

special thanks to Boblebad

Hi guys
Here it is completed for products and for rows:
Best Regards.
// Number of products to show per page ex 12

add_filter( 'loop_shop_per_page', function ( $cols ) {
return 12;
}, 20 );
// Number or products per row ex 4
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 4; // 5 products per row

Will this change stick after a WooCommerce update?

Aravin commented Jun 10, 2016

Not working for me. I can see the dropdown with options.

After choosing the option, there is no action.


zoldos commented Oct 16, 2016

Worked great!

Thanks a lot ! that works like cream 👍

Works beautifully. Thank you!

Thanks :)!


ghost commented Mar 21, 2017

@jameskoster Great It's working for me :)

Not sure if I'm doing something wrong, but it's not working for me :/

I'm using a child theme for the Divi theme ( and added the code to my functions.php, but my store still shows just 9 products per page. If anyone has any idea what I might be doing wrong, I would appreciate it immensely. Thank you.

@vivoeusebio there is an option in the divi settings

paaljoachim commented Jul 11, 2017

I had a similar problem with a client site and have received some help from X theme support on the correct shortcode to use:

[product_category category="plakat-30x40cm" number="26" per_page="26"]

It worked well for the client site.

put this code for my theme functions.php or new create wocommerce functions.php

Josepek commented Aug 5, 2017

Oh! greats!

This Plugin works fantastic, no need to change your coding, just install the plugin, change the amount of products you want and change the amount of rows also.

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