Support » Plugin: WordPress Infinite Scroll - Ajax Load More » Returning Duplicate Items at the beginning and end of the loop

  • Resolved dexter_ade

    (@dexter_ade)


    Hello, I have the problem the custom post type called “issues” are duplicated the 2 most recent posts at the beginning and end of the loop of my page, this happens when I add order = “ASC” in the shortcode.

    My code:

    <div class="right">
            <?php
              $the_query = new WP_Query( array(
                'posts_per_page' => 15,
                'post_type' => 'issues'
              ) );
            ?>
            <div class="grid issues thumbs mtxs">
              <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                <div class="issue">
                  <a href="{{ get_the_permalink() }}">
                    <figure class="lazy-container">
                      <img
                        class="b-lazy"
                        src="{{ the_post_thumbnail_url('thumbnail') }}"
                        data-src="{{ the_post_thumbnail_url('large') }}"
                        alt="{{ get_the_post_thumbnail_caption() }}"
                      />
                    </figure>
                    <p class="issue-number mb0"><?= get_field('number'); ?></p>
                    <p class="issue-title mt0">{{ the_title() }}</p>
                  </a>
                </div>
              <?php endwhile; ?>
            </div>
    
            <?= do_shortcode('[ajax_load_more offset="15" post_type="issues" container_type="div" css_classes="grid issues thumbs" transition_container="false" pause="true" posts_per_page="15" scroll="false" transition="none" order="ASC" button_label="Load More"]'); ?> 
    </div>

    This are two firsts recent posts http://prntscr.com/n2viwr and this last http://prntscr.com/n2vjtb

    Test with Version 5.0.0 and Version 5.0.1

    How I solve this?
    Thank you for you help.

    • This topic was modified 3 months ago by  dexter_ade.
    • This topic was modified 3 months ago by  dexter_ade.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author dcooney

    (@dcooney)

    Hi @dexter_ade

    If you are using your own query before ALM you need to use the offset parameter to offset the post load.

    Also you will want to use wp_reset_query() before you load ALM to reset any global bats in the loop.

    Hope this helps.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.