Exclude Post Type from Jetpack Infinite Scroll

I'm using the Underscores theme which comes with the following (very) handy code in inc/jetpack.php

add_theme_support( 'infinite-scroll', array(
    'container' = 'main',
    'render'    = 'infinite_scroll_render',
    'footer'    = 'page',
    'wrapper'   = false
) );

function infinite_scroll_render() {
  while ( have_posts() ) {
    the_post();
    if ( is_search() ) :
        get_template_part( 'template-parts/content', 'search' );
    else :
        get_template_part( 'template-parts/content-', get_post_type() );
    endif;
  }
}

I can't figure out the best way to edit either of these functions to ignore a particular post type. I can pass if( is_post_type_archive('service') ) but if I just 'return' then the rest of the page doesn't render - it just stops there.

How can I specify which post types Infinite Scroll fires on?

Topic infinite-scroll plugin-jetpack custom-post-types Wordpress

Category Web


Stand down! I got it with 'pre_get_posts':

add_action( 'pre_get_posts', 'pre_service_archive' );
function pre_service_archive() {
    if( is_post_type_archive( 'service' ) ) remove_theme_support( 'infinite-scroll' );
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.