• Resolved nanoo_k

    (@nanoo_k)


    I’m using Jetpack’s infinite blog to display posts. I also use WooCommerce to control my gift shop items.

    Problem is that WooCommerce uses Jetpack’s infinite scroll function. How could I make WooCommerce to maintain pagination?

    I’ve tried modifying the add_theme_support line in functions.php like this…

    function init_infinite_scroll() {
       if ( !is_page( 'woocommerce' ){
          add_theme_support( 'infinite-scroll', array(
               _ARGS
    	   ) );
       }
    }

    But that didn’t work.

    I also tried controlling where new content is appended by changing the container name from ‘content’ (the default) to ‘infinite-content.’

    function init_infinite_scroll() {
       add_theme_support( 'infinite-scroll', array(
            'container'  => 'infinite-content',
    	) );
    }

    So far that doesn’t work either.

    Does anyone have any ideas? How do I disable infinite scroll functionality on specific pages like WooCommerce product pages?

    http://wordpress.org/plugins/jetpack/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Is your page name “Woocommerce”?

    If so, you could try to remove Infinite Scroll from this page by adding the following code to your theme’s functions.php file:

    function tweakjp_custom_is_support() {
        $supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() ) && ( !is_page( 'woocommerce' ) );
    
        return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );

    Let me know if it helps.

    Thread Starter nanoo_k

    (@nanoo_k)

    I’m working on the same problem. Your code, Jeremy, worked by using WooCommerce’s own conditional tags. Here’s how my function wound up:

    // Disable infinite scroll on WooCommerce pages
    function tweakjp_custom_is_support() {
        $supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() ) && ( !is_woocommerce() );
    
        return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );

    After doing that, I can set the number of items per page by going to WordPress > Reading > “Blog pages show at most.” I can show all items by setting that to “-1”, but if I show less, I don’t get pagination. So I’m trying to get pagination back. Any ideas?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    So I’m trying to get pagination back. Any ideas?

    In this case, you should deactivate the Infinite Scroll module altogether. You can follow the instructions here to learn how to deactivate a Jetpack module:
    http://jetpack.me/support/#turn-off-jetpack-modules

    Plugin Contributor Elio Rivero

    (@eliorivero)

    Hi nanoo_k, you should not use the is_woocommerce function just like that: while it’s indeed convenient, if you ever deactivate the WooCommerce plugin your site will go blank since that function will no longer be available and not finding it will cause a fatal error.

    Instead, you should use something like

    /**
     * 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' );

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Suppress Infinite Blog with WooCommerce’ is closed to new replies.