ūüéČ Announcement: We just released the WooCommerce add-on for Ajax Load More that offers automatic integration into existing WooCommerce shop templates with zero configuration.
View Add-on.

WooCommerce is the most popular eCommerce platform on the internet Рit powers over 28% off all online stores. Today, we are going to cover how to implement WooCommerce infinite scrolling with the free Ajax Load More plugin for WordPress.

Before we begin, make sure you have both Ajax Load More and WooCommerce activated and products have been created so there is content ready for infinite scrolling ūüôā

Note: The following guide and examples reference code from the official WooCommerce theme, Storefront.

**July 2019 Update**

Version 5.1 of Ajax Load More introduced built-in support for WooCommerce on pages, templates and product archives using the woocommerce shortcode parameter.

Read more about the new integration in the Building a Shortcode section below.


There are essentially four steps to WooCommerce infinite scrolling with Ajax Load More. None of the steps are overly difficult to complete, but you will be required to make modifications to core WooCommerce templates during the process.

The implementation steps are as follows:

  1. Create Child Theme
  2. Create Repeater Template
  3. Building a Shortcode
  4. WooCommerce Template

Alright, let’s go!

Create Child Theme

Since this tutorial will require modifying core theme template files the first step will be to create a child theme – this will allow us to make modifications and not worry about conflicts when theme updates are applied.

There are many resources available online that explain exactly how to create a child theme so I won’t go into anymore detail on how to do that today.

Create Repeater Template

Next, you’ll want to create a unique¬†WooCommerce¬†Repeater Template for displaying your products,

Most WooCommerce compatible themes use a variation of default content-product.php template while iterating over products so you may be fine by simply copying the following template into your Ajax Load More Repeater Template.

Note: The template above was copied directly from WooCommerce core – I recommend inspecting your theme in the off chance it is using a modified version of the template.

Building a Shortcode

After creating the Repeater Template, you should build out a WooCommerce specific shortcode. The WooCommerce shortcode instructs Ajax Load More on what content to include while infinite scrolling the products.

Shop Home/Landing Page

For a shop homepage or generic landing page, you simply need to set woocommerce=”true” in the core Ajax Load More shortcode.

With woocommerce set as true, Ajax Load More will automatically set product as the post_type parameter and products as the css_classes parameter for the Ajax query.

Note: The majority of WordPress themes and plugins use .products as the container classname for styling WooCommerce product listings. 

Product Archives

On product archive pages, Ajax Load More will automatically detect the current term and taxonomy (e.g. product_tag or product_cat) and then behind the scenes it will set the corresponding taxonomy, taxonomy_terms, post_type and css_classes shortcode parameters.

Pro Tip: Use the css_classes shortcode parameter to add additional classes to the Ajax Load More container.

Manual Implementation

It’s not mandatory to use the built-in WooCommerce integration, you can always decide to manually build an Ajax Load More shortcode.

The code snippet above is an example of retrieving WooCommerce products on a taxonomy archive page.

WooCommerce Template

The final step is to clone and modify the archive-product.php template from /plugins/woocommerce/templates/ to the root of your current theme directory. This template used for displaying WooCommerce products so modifying this file directly will allow you to place the Ajax Load More shortcode into the correct location.

Pro Tip: Your theme may already be using custom WooCommerce templates – in that case you should modify those templates and not core WooCommerce templates as referenced below.

Once the template has been cloned, open the file in your code editor and select everything from the opening if(wc_get_loop_prop(‘total’)){¬†to the closing¬†} bracket of the conditional statement. You will want to replace the selected contents, including the while() loop with the following Ajax Load More specific code.

Click here to view the complete archive-product.php template.

With the template updated and steps 1 thru 4 complete you should have a working WooCommerce infinite scroll – check out the following links to see our code implemented on a shop homepage and product archive.

Wrapping Things Up

It might seem like a lot of tasks to implement WooCommerce infinite scrolling, but keep in mind at the end of the day all you’re really doing is replacing the default WooCommerce loop with Ajax Load More.

Got any WooCommerce specific questions or suggestions? Leave them in the comments and I’ll do my best to help you out!


28 thoughts on “Infinite Scroll WooCommerce Products with Ajax Load More”

  1. Avatar


    November 03, 2020 @ 4:21 am

    Nevermind, I realized product attributes are treated as taxonomies in your shortcode, all good! thanks for the great plugin.

  2. Avatar


    June 03, 2020 @ 7:24 pm

    hi Darren Cooney amazing Plug-in thanks!

    Im trying to implement the masonry option but im having the “Uncaught TypeError: Cannot read property ‘style’ of undefined” i read your FAQ but the repeater i’m using is what you put in the tutorial

    with this shortcode [ajax_load_more loading_style="infinite skype" woocommerce="true" posts_per_page="6" repeater="default"] every works like a charm

    but with this one [ajax_load_more loading_style="infinite skype" woocommerce="true" posts_per_page="6" repeater="default" transition="masonry" masonry_selector=".product" ]

    i have this error i put the .product in the masonry_selector because it the markupof the woocommerce template but i try the .grid-item also no luck! i I also added the css that you explain in the masonry example page. Try to find info everywhere about this error no luck!

    Thanks and hope you can help me!

    1. Avatar

      Darren Cooney

      June 04, 2020 @ 9:06 am

      Hi Bruno,
      Thanks! This error usually means there an issue in the Repeater Template.

      Can you possibly share a link to the issue?

      1. Avatar


        June 04, 2020 @ 9:14 am

        Thanks for the reply I already see that faq but im using the repeater temlate:
        wc_get_template_part( ‘content’, ‘product’ );

        link: https://shop.brunodasilva.pt/catalog/

        if i remove the transition=”masonry” masonry_selector=”.product” option of the shortcode works perfectly

        thanks again for your support

        1. Avatar

          Darren Cooney

          June 04, 2020 @ 9:35 am

          Interesting. TBH I’ve never tried WooCommerce with masonry so I would have to test it.

          If you want, open a support ticket and i can follow up over email. Unless you’re fine without Masonry.

          1. Avatar


            June 04, 2020 @ 9:43 am

            I opened support ticket! thanks

  3. Avatar


    February 03, 2020 @ 8:54 am

    Hi, I am trying your plugin with easy property listing plugin, it works wonderfully but have a small glitch, it doesn’t allow shortcode to run properly , like post_type=”property,land” sortby=”status” , here sortby=”status” doesn’t work means only the first part works but not second or third

    here is a sample of code

    [ajax_load_more listing  post_type="property,land" sortby="status" listing limit="30"  tools_top="on" status="sold" container_type="div" transition_container_classes="css-grid" posts_per_page="6"  button_label="Load More" button_loading_label="Wait, Data Loading !!!!!!!"]

    Any guidance shall be highly appreciated and 5 Stars

    1. Avatar

      Darren Cooney

      February 03, 2020 @ 11:59 am

      Hi Satinder,
      `sortby` and `listing limit` are not valid shortcode parameters for Ajax Load More.

      To add a custom parameter you could use the following filter or the custom_args parameter.

      `[ajax_load_more custom_args="sortby:status"]`

      Let me know if this helps at all.

  4. Avatar

    Joao Sarmento

    October 09, 2019 @ 6:14 am


    can this plugin be used to retrieve Products across a woocommerce multiste installation?


    They will all have the same plugins, but Woocommerce will have different campaigns (using a crowdfunding plugin) in each sub folder.

    They will have different currencies (Pounds and Euro).

    Can the plugin be used to do a search on example.com and retrieve the campaign data from /uk and /france and show the results on example.com ?

    Please let em know.



    1. Avatar

      Darren Cooney

      October 09, 2019 @ 10:36 am

      Hi Joao,
      Unfortunately I’m not sure about this one.

  5. Avatar


    October 08, 2019 @ 5:03 am

    I have got Ajax Load More 95% working I think. I am not sure if this is an compatibility issue with your plugin and Woo Side Cart Plugin but I cant get the “Add to Cart” Button to obtain the correct parameters so that it adds the item to the cart rather than open up the single product page.

    I have used the “create” repeater template (above) and the a href rel=”nofollow” comes back “/wp-admin/admin-ajax.php?id&post_id=9400&slug=scroll-test&canonical_url=https%3A%2F%2Fchromalytic.net.au%2Fscroll-test%2F&posts_per_page=15&page=0&offset=0&post_type=product&repeater=default&seo_start_page=1&preloaded=false&preloaded_amount=0&taxonomy=product_cat&taxonomy_terms=male-luer-integral-lock-ring&taxonomy_operator=IN&order=DESC&orderby=date&action=alm_get_posts&query_type=standard&add-to-cart=5317”
    instead of

    I have created a scroll-test page so that you can see what happens and the differences in what I am wanting to achieve. The page has my original section using a default pagination shortcode/plugin that I want to eventually replace with your Ajax load more plugin (in the section below).


    Hopefully I have made sense – I have a feeling I just need to create an appropriate repeater template – but I am not great with php or understanding the woocommerce hooks / templates

    1. Avatar

      Darren Cooney

      October 08, 2019 @ 3:17 pm

      Hey Matthew,
      This looks as though Woo Side Cart is not using the correct HTTP referral link to build it’s Add to Cart URLs. It’s using the URL in the Ajax reqeust.

      I think you might be best to open a ticket with them on this and let them know that Add to Cart URLs are not the correct URL when being loaded via admin-ajax.

      1. Avatar


        October 08, 2019 @ 9:57 pm

        Hi Darren,

        Thanks for your reply. I will open a support ticket with them, but not sure it is related to Woo Side Cart Plugin.
        I have disable the WSC Plugin and the linking issues are still the same regarding the Product List from Top Section of the page to the bottom section under the Older Posts button (which is generated from your plugin.
        This time when I click “add to cart” button (same link a previous), it stays on the page and displays a “view cart” button underneath.
        The “add to cart” button that is under the Older Posts Section has the same link as previous and when clicked gets redirected to the Single Product Page

        I have a feeling it has something to do with the hook
        do_action( ‘woocommerce_after_shop_loop_item’ );
        which initiates/display the add to cart button. Maybe the template has been modified somehow but I would not know where/how to check. Or is there an alternative command I can try?

        1. Avatar

          Darren Cooney

          October 09, 2019 @ 12:01 pm

          This may be an issue in your particular theme where the JS is not triggering.

          Seems to be working on my testing site.

  6. Avatar


    August 19, 2019 @ 8:52 pm

    Hi, I have implemented the Auto Scroll as directed and it worked. the only issue I have is that the format chnaged. What was 3 across in a grid is now 1 across in a list with the date added! Is there anything I need to add to the shortcode to retain the format?

    1. Avatar

      Darren Cooney

      August 20, 2019 @ 9:13 am

      Hey Nick,
      I think you may have missed the section on creating your own the Repeater Template.

      Let me know if you have troubles.

  7. Avatar


    June 01, 2019 @ 3:29 am

    Hi Darren,

    I have done the following steps to make it work for my WooCommerce store site with flatsome theme.
    1. copied block from content-product.php to default(repeater) template in uploads folder.
    2. cloned archive-product template from /plugins/woocommerce/templates/ to root folder of my child theme. file path in my case is /themes/flatsome-child/archive-product.php
    3. Nested following code block to if ( wc_get_loop_prop( ‘total’ ) )
    {ALM code bock(if/else) here} section in archive-product template:

    ALM Code Block Inserted:

    if(is_archive()){ // Product Archives

    $obj = get_queried_object();
    $taxonomy = $obj->taxonomy; // Get taxonomy
    $taxonomy_term = $obj->slug; // Get term
    echo do_shortcode(‘[ajax_load_more post_type="product" taxonomy="'. $taxonomy .'" taxonomy_terms="'. $taxonomy_term .'" taxonomy_operator="IN" css_classes="products" posts_per_page="6" transition="fade"]‘);

    } else { // Shop Landing Page

    echo do_shortcode(‘[ajax_load_more post_type="product" css_classes="products" posts_per_page="6" transition="fade"]‘);


    Its not working. Can you please point out what i am doing wrong here.

    1. Avatar


      June 03, 2019 @ 2:59 am

      Hi Darren,

      The issue is fixed by moving archive-product file from child theme root to woocommerce folder created under child theme root.
      But now the issue is that my theme layout is broken:
      1. sidebar is not showing on left side but below the products
      2. single product is showing instead of 4 in case of desktop and 2 in case of mobile
      Can you please help me fix this.
      And do you have a plan to integrate woocommerce feature in plugin options?


      1. Avatar

        Darren Cooney

        June 10, 2019 @ 9:10 am

        Hi Ismail,
        Oh, nice work. Glad to hear it’s sorted.

  8. Avatar

    John Negoita

    May 19, 2019 @ 1:56 am

    hi Darren,

    I’m trying to implement ALM with masonry for my products in Woo.
    and I’m doing this in the archive-product.php

    echo do_shortcode(‘[ajax_load_more post_type="product" taxonomy="'. $taxonomy .'" taxonomy_terms="'. $taxonomy_term .'" taxonomy_operator="IN" css_classes="products" posts_per_page="6" transition="masonry" masonry_selector=".grid-item"]‘);

    But, I’m getting this JS error:

    Cannot read property ‘style’ of undefined at new ajaxloadmore (ajax-load-more.js:122)

    When debugging it seems that the code expects the element alm-btn-wrap to be inside the ajax-load-more-wrap element, but it’s actually outside

    What am I doing wrong?


    1. Avatar

      Darren Cooney

      May 21, 2019 @ 8:17 am

      Hey John,
      This error is usually related to an issue in the repeater template. If a template is closing an extra div, ALM can lose the positioning of the button.
      Can you share your template in a Gist or something?

  9. Avatar


    May 03, 2019 @ 4:39 pm

    Would it be possible to connect the shortcode with woocommerce’s attributes filter widget so users can sort by size / color?, I already tried adding the parameters in the shortcode and fetching the values from the URL via $GET[‘filter_size’] but I must be doing something wrong because no products are shown.

    1. Avatar


      May 03, 2019 @ 5:18 pm

      Nevermind, I realized product attributes are treated as taxonomies in your shortcode, all good! thanks for the great plugin.

      1. Avatar

        Darren Cooney

        May 04, 2019 @ 10:23 am

        Yes, you need to pass the taxonomies into the shortcode. I hope to make this easier for everyone soon, but for now it’s sort of a manual process.
        Glad it’s working for you!

        1. Avatar


          May 06, 2019 @ 1:37 pm

          Thank you so much, yeah I got that working and I’m just missing one thing, I don’t know if it’s possible. Is there a way to also pass the product price range values? Thank you!

          1. Avatar

            Darren Cooney

            May 08, 2019 @ 11:49 am

            Can you show me an example?

  10. Avatar


    October 03, 2018 @ 9:11 pm

    Would it be possible for you to make a video explaining these steps as you go along? I’m not a computer science major and I’m pretty much faking it until I make it with this stuff… It’s super cool in theory, but I honestly have no idea what I’m doing and videos are much more helpful than written instructions because I can follow along as you go. Thanks!

    1. Avatar

      Darren Cooney

      October 06, 2018 @ 12:12 pm

      Hi Jeremy,
      My plan is to start creating more video content very soon.

Leave a Reply

Your email address will not be published. Required fields are marked *