• For a reason I can’t understand (due my low programing skills) when Infinite Scroll loads the new content, it repost the already loaded posts but the five first… I mean, the new loaded content begins at the 6th post of the 32 that load at document ready.

    I played around with configuration but still I can’t figure out what I’m or missing or doing wrong.

    I implemented Infinite Scroll using template parts like this:

    <?php if(have_posts()) : ?>
              <?php while(have_posts()) : the_post(); 
    
                // El cuerpo del post está en content.php
                get_template_part( 'content', get_post_format() );
    
              endwhile; else: ?>
    
              <div class="large-12 medium-12 columns">
                <h2>Ups</h2>
                <p>Vaya, parece que aún no hay artículos publicados aquí...</p>
              </div>
    
            <?php endif; ?>

    that loads this:

    <div id="post-<?php the_ID(); ?>" class="caja-post columns">
      <div class="extracto-post">
        <div class="extracto-imagen-caja">
          <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">
            <div class="extracto-imagen">
              <?php the_post_thumbnail('post'); ?>
            </div>
          </a>
        </div>
        <div class="extracto-info">
          <div class="extracto-categoria"><?php the_category(' · ') ?></div>
          <div class="extracto-autor"><?php the_author_posts_link(); ?></div>
          <div class="extracto-fecha"><?php echo date_i18n('j \d\e\ F \d\e\ Y', time()); ?></div>
        </div>
        <?php edit_post_link('Editar', ''); ?>
        <h3 class="extracto-titulo">
          <a title="Ver <?php the_title(); ?>" href="<?php the_permalink(); ?>" >
            <?php the_title(); ?>
          </a>
        </h3>
        <p class="extracto-texto">
          <?php echo get_the_excerpt(); ?>
        </p>
      </div>
    </div>

    and with this configuration:

    /* Scroll Infinito */
    function code_new_infinite_scroll_init() {
    	add_theme_support( 'infinite-scroll', array(
    	    'container'      => 'loop',
    	    'footer' 		 => false,
    	    'posts_per_page' => '32',
    	    'wrapper'		 => 'infinite-posts'
    	) );
    }
    add_action( 'init', 'code_new_infinite_scroll_init' );

    The theme is a custom one, and I didn’t set post offsets anywhere

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Brandon Kraft

    (@kraftbj)

    Code Wrangler

    Could you post your site URL here, so I can have a look?

    If you want it to remain private, you can also contact us via this contact form:
    https://jetpack.me/contact-support/

    32 is pretty high, so curious to see what you’re loading it into.

    Thread Starter hectorasencio

    (@hectorasencio)

    Hi Brandon, thanks for reply!

    The number is a kind of fallback if the plugin is deactivated, and now I’m loading 30 posts because the client ask me for a diferent layout.

    Playing around and trying to figure out what happen, I noticed that repetitions are diferent depending what category is; ‘Actualidad’ category repeats from the first, ‘Vida’ repeats from the second, ‘Dinero’ from the third, ‘Entretenimiento’ from the first again, ‘Deportes’ from the second again, ‘Musica’ from the first, ‘Humor’ from the first and ‘Videos’ do it from the third.

    In author and search results pages pages I also get this random behaviour. All repetitions begins at 31 position and the weird thing is that it changes in my local seup with an old version of database and get me diferent numbers…

    You can take a look at here:
    https://testing.codigonuevo.com

    Plugin Author Brandon Kraft

    (@kraftbj)

    Code Wrangler

    Are any of them, by chance, sticky posts? The differing numbers is odd, so that’s a random guess of something that may factor into it.

    IS will repeat the main query used on the page, skipping the initial number of posts (or should at least!). What’s the query you’re using?

    Thread Starter hectorasencio

    (@hectorasencio)

    No sticky posts. I’m using the regular loop at index.php:

    <?php if(have_posts()) : ?>
              <?php while(have_posts()) : the_post(); 
    
                // El cuerpo del post está en content.php
                get_template_part( 'content', get_post_format() );
    
              endwhile; else: ?>
    
              <div class="large-12 medium-12 columns">
                <h2>Ups</h2>
                <p>Vaya, parece que aún no hay artículos publicados aquí...</p>
               </div>
    
            <?php endif; ?>

    But I read somwhere that custom queries would affect the behaviour of the main loop. So, in the sidebar I’m using this:

    <?php
                $args=array( 'category_name' => 'Video', 'posts_per_page' => 4 );
                $Loop = new WP_Query($args);
    
                if($Loop->have_posts()) : while($Loop->have_posts()) : $Loop->the_post();?>
                <div class="extracto-post">
                  <div class="extracto-imagen-caja">
                    <a class="extracto-imagen" title="Ver <?php the_title(); ?>" href="<?php the_permalink(); ?>">
                      <?php the_post_thumbnail('portada'); ?>
                      <i class="fa fa-youtube-play"></i>
                    </a>
                  </div>
                  <h3 class="extracto-titulo">
                    <a title="Ver <?php the_title(); ?>" href="<?php the_permalink(); ?>">
                      <?php the_title(); ?>
                    </a>
                  </h3>
                </div>
    
              <?php endwhile; endif; ?>

    and this:

    <?php query_posts('meta_key=post_views_count&orderby=meta_value_num&posts_per_page=4');
                if (have_posts()) : while (have_posts()) : the_post(); ?>
                <div class="extracto-post extracto-mini">
                  <div class="extracto-imagen-caja">
                    <a class="extracto-imagen" title="Ver <?php the_title(); ?>" href="<?php the_permalink(); ?>">
                      <?php the_post_thumbnail('portada'); ?>
                    </a>
                  </div>
                  <h3 class="extracto-titulo">
                    <a class="extracto-imagen" title="Ver <?php the_title(); ?>" href="<?php the_permalink(); ?>">
                      <?php the_title(); ?>
                    </a>
                  </h3>
                </div>
              <?php endwhile; endif; wp_reset_query(); ?>

    And the query I used at footer is this:

    <?php $args = array('exclude' => '1,2'); $categories = get_categories($args);
                      foreach($categories as $category)
                      {
                        echo '<a title="'.$category->name.'" href="'.get_category_link( $category->term_id ).'">'.$category->name.'</a>';
                      }
                    ?>

    Thanks for your time!

    Plugin Author Brandon Kraft

    (@kraftbj)

    Code Wrangler

    I haven’t tested your code, but the first thing I notice is using query_posts, which definitely can impact things in odd ways.

    Could you rework that like the snippet above (with the new WP_Query method), just to eliminate that as any possible source of the issue?

    Thread Starter hectorasencio

    (@hectorasencio)

    I’ve eliminated the whole query_post and the error is still shown at the same point…

    I also tried to deactivate all the plugins but no luck.

    I have the same problem.

    im having same problem. 5th and 6th post or if i loop 9 post then 8th or 9th post is duplicating in next infinity loading. That means total 2 post only duplicating. Can any one help me i m having hard time.

    I use sticky post query on top of page. Then looping post with infinity scrolling admin-ajax.php. Sticky post arent duplicating instead of other 2 post live site https://www.babyzone.mn

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Infinite Scroll duplicate posts from 6th one’ is closed to new replies.