• Resolved bolteh

    (@bolteh)


    Hi,

    I’m trying to get the infinite scroll feature to work on my custom theme (created from scratch). Everything appears to be working, apart from the fact that it’s not actually loading additional posts.

    When the type is set to “scroll”, the spinning thingy appears, but no posts are loaded. When the type is set to “click”, the button appears, but clicking it only shows the spinning icon for a second, but nothing loads.

    This is in my functions.php:

    add_theme_support( 'infinite-scroll', array(
    	'container'  => 'contentposts',
    	'footer' => false,
    	'type' => 'click',
    ) );

    And this is the loop code I’m using on home.php:

    <div id="contentposts">
    		<?php if ( have_posts() ) : ?>
    		<?php while ( have_posts() ) : the_post(); ?>
    		<?php get_template_part( 'content', get_post_format() ); ?>
    
    			<div class="post">
    			<?php if (has_post_thumbnail()) : ?>
    				<div class="entry-image">
    					<a href="<?php the_permalink(); ?>" target="_parent" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
    				</div>
    			<?php else : ?>
    			<?php endif; ?>
    				<div class="entry-header">
    					<div class="post-edit">
    						<a href="<?php echo get_edit_post_link( $id, $context ); ?>" target="_parent" title="Edit">Edit post</a>
    					</div>
    					<div class="entry-data">
    						<span><?php the_date(get_option('date_format')); ?></span>
    					</div>
    					<h1 class="entry-title"><a href="<?php the_permalink(); ?>" target="_parent" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
    				</div>
    				<div class="entry-content">
    					<?php the_excerpt(); ?>
    					<a class="button" href="<?php the_permalink(); ?>" target="_parent" title="<?php the_title(); ?>">Read more</a>
    				</div>
    			</div>
    
    		<?php endwhile; ?>
    			<?php else : ?>
    				<div class="post">
    					<div class="entry-post">
    						<h1>No posts were found.</h1>
    					</div>
    				</div>
            <?php endif; ?>
    </div>

    Am I missing something here?

    I can’t link to a live website, because I’m currently developing on a MAMP server.

    PS: MAMP isn’t the problem. The infinite scroll feature does work with the Twenty Fifteen theme, so it’s something that’s wrong with my custom theme.

    Thanks in advance.

    https://www.ads-software.com/plugins/jetpack/

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

    (@jeherve)

    Jetpack Mechanic ??

    You include <?php get_template_part( 'content', get_post_format() ); ?> after starting the loop. Could you let me know what you’ve added in your content*.php files?

    Thread Starter bolteh

    (@bolteh)

    Thanks for your answer.

    I actually don’t have a content.php (this is the first time I’m creating a theme for WordPress from scratch).

    I just found that piece of code somewhere and figured U just had to copy paste it in my code.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Jetpack’s Infinite Scroll will look for code in template parts in the content-{post format}.php form, so if yours is empty, nothing will be returned.

    You’ll consequently need to move the content of your loop in there, like it’s done in the default themes, or change where Infinite Scroll looks for content, thanks to the render option. You can read more about it here:
    https://jetpack.me/support/infinite-scroll/

    It might also be worth checking how a starter theme like _s creates its loop:
    https://github.com/Automattic/_s

    You could even start with that theme when creating your own theme.

    I hope this helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Infinite scroll spinning, but not loading posts’ is closed to new replies.