• Resolved TheAustinG

    (@theausting)


    Not sure what is causing this but I’m sure it’s an error that I made when editing the repeater template and I’m just not catching it. Hopefully someone here can help though.

    Basically I have it set to load 5 posts at a time (that’s also what I have WordPress defaulted to show). When I click on the button to load more it loads those first 5 again. Then when I click it one more time it loads the next 5 posts (how it should have done it the first time).

    Anyways, here is the code for my repeater template as I imagine that’s what’s causing the duplication. Let me know if I need to post anything else though.

    <div>
    <?php if ( has_post_thumbnail() ): {
    $src = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
    }?>
    <div class="featured-image-full-width" style="background-image: url( <?php echo $src; ?> ) !important; height: 400px; background-size: cover; background-repeat: no-repeat; background-position: center;"></div>
    <?php endif; ?>
    
    <header class="entry-header">
    <?php the_title( sprintf( '<h2 class="entry-title">', esc_url( get_permalink() ) ), '</h2>' ); ?>
    </header>
    
    <div class="entry-content">
    <?php
    the_excerpt( sprintf(
    wp_kses( __( 'Continue reading %s <span class="meta-nav">→</span>', 'tct-redi' ), array( 'span' => array( 'class' => array() ) ) ),
    the_title( '<span class="screen-reader-text">"', '"</span>', false)
    ));
    ?>
    
    <hr />
    
    </div>
    </div>

    https://wordpress.org/plugins/ajax-load-more/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Really weird. Repeater looks ok.
    Can you share a link?

    Thread Starter TheAustinG

    (@theausting)

    I have sent you the url to my site using the contact form on your site. Looking forward to hearing back from you 🙂

    Thread Starter TheAustinG

    (@theausting)

    dcooney helped me through email to solve this problem. Just in case anyone else runs into this issue it was a very easy fix!

    Since WordPress is already loading the first 5 posts I needed to change the offset of the Load Ajax to 5 so that it ignores the first 5 posts. Once I did that it worked perfectly!

    This is what dcooney said

    Well your first 5 posts are not even loaded Ajax Load More – so when the plugin fetches your next posts it doesn’t know they are on the page.

    You need to set offset=”5″ in order to start the loading at 5, 6, 7, 8, 9 etc…

    Thanks again for the awesome support and plugin!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Duplicating first 5 posts’ is closed to new replies.