I have this loop and I don’t know why, I have a “load more” button and when I click on it, it loads all articles a second time.

Can someone help ?

<div class="content">
<div class="container load_more">
  <div class="row">

  <?php

  $args = array("post_type" => 'any');
  $the_query = new WP_Query ($args);?>
  <?php
  if($the_query->have_posts()):
  while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
  <div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
    <div class="le_post_entier ">
      <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('actus'); ?></a>
      <div class="col-md-12 postbody ">
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
        </div>
        <a class="cta" href="<?php the_permalink(); ?>">DÉCOUVRIR →</a>
      </div>
    </div>

  <?php  endwhile; wp_reset_postdata();endif;
?>
</div>
</div>
</div>

<?php get_footer(); ?>

Read more here: Why does it loop twice ?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: