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">


  $args = array('category_name' => 'actu, quizz' );
  $the_query = new WP_Query ($args);?>
  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(); ?></a>
        <a class="cta" href="<?php the_permalink(); ?>">DÉCOUVRIR &#8594;</a>

  <?php  endwhile; ;endif;

UPDATE I've closed the tags but it still loop twice

  • Where is the code for the load more button? – Milo May 11 '17 at 13:04
  • Hello, it's a plugin called WP Load More Posts – ferdi_ May 11 '17 at 13:07
  • Have you asked the person who created the plugin? We don't know how that plugin works. – Milo May 11 '17 at 13:08
  • I use it on an other page of my site and it doesn't load twice – ferdi_ May 11 '17 at 13:28
  • 2
    Your query doesn't specify what page of results you want returned, so it will always return the first page. But again, we don't know how that plugin works, so I can't say how to fix that. – Milo May 11 '17 at 15:12

I agree with Takebo it's problem with tag.

<div class="col-md-12 postbody "> <a href="<?php the_permalink(); ?>"><?php the_title(); ?>

here is missing </a>

    <a class="cta" href="<?php the_permalink(); ?>">DÉCOUVRIR &#8594;</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.