MarketPress product archive and Infinite Scroll issue

Hi,

When using Jetpack’s Infinite Scroll and MarketPress there is a funny effect on product archive pages. Below the normal products list, there is a sort of repeat list, normal post style, generated by the Infinite Scroll module. For an example see http://m-etropolis.com/theshop/products/category/ebooks/ (scroll down to the end of the 14 products)

Is there any way to keep Infinite Scroll for normal posts while preventing this effect on Product listings?

Thanks for any tips :slight_smile:

  • Vaughan
    • Ex Staff

    Hi @RavanH,

    Can you try adding the following to your theme functions.php

    /**
    * Enables Jetpack's Infinite Scroll in search pages, disables it in product archives
    * @return bool
    */
    function tr_theme_jetpack_infinite_scroll_supported() {
    return current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() ) && ! is_post_type_archive( 'product' );
    }
    add_filter( 'infinite_scroll_archive_supported', 'tr_theme_jetpack_infinite_scroll_supported' );

    Hope this helps

  • RavanH
    • The Crimson Coder

    Hi @Vaughan – Thanks for your response!

    I pasted the code in the themes functions.php but it does not have any effect. Strange, it looks like it should…

    To test, I simplified the return line to:

    return is_post_type_archive( 'product' ) ? false : true;

    Still, this has no effect.

    And changing to:

    return is_post_type_archive( 'product' ) ? true : false;

    switches Infinite Scroll off everywhere, including the product archives!

    It seems like the product archive pages do not return true on is_post_type_archive(‘product’:wink: is that possible?

  • RavanH
    • The Crimson Coder

    Hi @Hoang Ngo – Yes! That did the trick :slight_smile:

    To recap: I’ll be using the code

    function my_theme_jetpack_infinite_scroll_supported() {
    return current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() ) && ! is_tax( 'product_category' );
    }
    add_filter( 'infinite_scroll_archive_supported', 'my_theme_jetpack_infinite_scroll_supported' );

    because it fixes the issue and I like the added support for Infinite Scroll on search pages. Marking this as resolved.

    But…

    It might be worth to consider adding a simplified version to MarketPress to fix this funny ‘double product list’ effect in combination with Infinite Scroll. It would prevent running into the same issue with each theme (that supports infinite scroll) in the network.

    In any case, thanks guys, for the support :slight_smile:

  • Hoang Ngo
    • The Green Incsub

    Hi @RavanH,

    I hope you are well today and glad to hear the functions worked :slight_smile:.

    It might be worth to consider adding a simplified version to MarketPress to fix this funny ‘double product list’ effect in combination with Infinite Scroll. It would prevent running into the same issue with each theme (that supports infinite scroll) in the network.

    I will notice the developer about this compatibility issue. So he can consider for this fix in the future release.

    If you have any issues please don’t hesitate to let us know so we can assist

    Best regards,

    Hoang