0

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?

0

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' );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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