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() ) {
    if ( is_search() ) :
        get_template_part( 'template-parts/content', 'search' );
    else :
        get_template_part( 'template-parts/content-', get_post_type() );

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?

1 Answer 1


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' );
  • This saved me! i hope it works! Mar 2, 2020 at 23:23
  • This does not appear to work for me. Also just adding remove_theme_support( 'infinite-scroll' ) unconditionally doesn't seem to do anything.
    – MastaBaba
    Aug 11, 2022 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.