0

I can get the loading indicator to show up but no more posts load. I've tried doing things with 'render' and the theme name, template-parts content instead of content.php, adding another div with id to the while loop. Any help would be great thanks.

index.php

<?php get_header(); ?>
<div class="tagline">
    <!-- General > Settings > Tagline -->
    <?php echo get_bloginfo( 'description' ); ?>
</div>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php get_footer(); ?>

content.php

<div id="content">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <section class="gallery">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

            <article class="post-item">

                <?php
if ( has_post_thumbnail()) {
echo '<a href="' . get_permalink($post->ID) . '" >';
the_post_thumbnail( 'thumbnail' );
echo '</a>';
}
?>
<h2 class="post-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="
<?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h2>

 </article>
 <?php endwhile; else: ?>
 <p>
 <?php _e('Sorry, no posts matched your criteria.'); ?>
 </p>
 <?php endif; ?>

 </section>

</article>
</div><!-- content -->

functions.php

add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => 'false'
) );
Pete
  • 11
  • 2
  • 6

2 Answers2

0

I've changed the functions.php to this and that's got the scroll working.

function my_theme_infinite_scroll_render() {
get_template_part( 'content' );
}
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'render'    => 'my_theme_infinite_scroll_render',
'posts_per_page' => 6,    
'footer' => 'false'
) );

Change my_theme to whatever your theme name is.

Pete
  • 11
  • 2
  • 6
0

Added 'wrapper' => false, so that the page scrolls back up fully after going back from a post and stops it adding /page/2 etc to the URL.

Also got rid of ' ' that I had around 'false' for the footer so now the footers gone properly.

function my_theme_infinite_scroll_render() {
get_template_part( 'content' );
}
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'render' => 'my_theme_infinite_scroll_render',
'wrapper' => false,
'posts_per_page' => 6,    
'footer' => false
) );
Pete
  • 11
  • 2
  • 6