• Resolved openbayou

    (@openbayou)


    Hi,
    I have infinite scroll up and running, only problem is that is loads posts but not posts in a custom post type. Any ideas on how to solve this?

    This is what my index.php looks like:

    <?php get_header();?>
    
    <section id="main">
    
    <?php $loop = new WP_Query( array( 'post_type' => array('post','announcements'),'paged' => $paged ) ); ?>
    <?php if ($loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    <?php get_template_part( 'content', get_post_format() ); ?>
    
    <?php endwhile; else : ?>
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>
    
    </section>
    
    <?php get_footer();?>

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

Viewing 1 replies (of 1 total)
  • Thread Starter openbayou

    (@openbayou)

    Got it working:

    function jetpack_infinite_scroll_query_args( $args ) {
        $args['post_type'] = array('announcements','post');
        $args['posts_per_page'] = 10;
    
     	return $args;
    }
    add_filter( 'infinite_scroll_query_args', 'jetpack_infinite_scroll_query_args' );
    add_theme_support( 'infinite-scroll', array(
        'container' => 'main',
        'footer_widgets' => false,
        'posts_per_page' => 10,
    ) );
Viewing 1 replies (of 1 total)
  • The topic ‘[infinite scroll] doesn't load custom post types’ is closed to new replies.