• Resolved turakvlad

    (@turakvlad)


    I’ve created custom post type with “CPT UI” plugin. I’ve added some custom posts via WordPress and loop through that posts in my static page – page-reviews.php. My loop:

    <?php
    
    $args = array(
    	'post_type' => 'reviews_type'
    );
    
    $query = new WP_Query( $args );
    
    if ( $query->have_posts() ) :
    
    	/* Start the Loop */
    	while ( $query->have_posts() ) : $query->the_post();
    
    		/*
    		 * Include the Post-Format-specific template for the content.
    		 * If you want to override this in a child theme, then include a file
    		 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    		 */
    		get_template_part( 'template-parts/content', 'reviews' );
    
    	endwhile;
    
    	the_posts_navigation();
    
    else :
    
    	get_template_part( 'template-parts/content', 'none' );
    
    endif; ?>
    
    <?php wp_reset_postdata(); ?>

    I have also added “Jetpack Infinite Scroll” support to my theme:

    function sandrasaenz_infinite_scroll_init() {
    	add_theme_support( 'infinite-scroll', array(
    		'container' 	 => 'main',
    		'render'    	 => 'sandrasaenz_infinite_scroll_render',
    	) );
    }
    add_action( 'after_setup_theme', 'sandrasaenz_infinite_scroll_init' );
    
    function sandrasaenz_infinite_scroll_render() {
        get_template_part( 'render' );
    }

    The problem is – it doesn’t work for me. I don’t have id="infinite-handle" in my HTML. What’s wrong with my code?

    Any help will be appreciated!

    https://wordpress.org/plugins/jetpack/

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

    (@jeherve)

    Jetpack Mechanic 🚀

    When you declared support for Infinite Scroll, you specified a specific loop, in render.php. Since your Custom Post Type uses a different loop, it won’t use Infinite Scroll.

    I would consequently recommend that you update your template structure and sandrasaenz_infinite_scroll_render to use a loop that is used by your Custom Post Type as well.

    I hope this helps.

Viewing 1 replies (of 1 total)

The topic ‘Jetpack Infinite Scroll with custom post type.’ is closed to new replies.