0

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

  <?php  endwhile; ;endif;
?>
</div>
</div>
</div>

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

6
  • Where is the code for the load more button?
    – Milo
    Commented May 11, 2017 at 13:04
  • Hello, it's a plugin called WP Load More Posts
    – ferdi_
    Commented May 11, 2017 at 13:07
  • Have you asked the person who created the plugin? We don't know how that plugin works.
    – Milo
    Commented May 11, 2017 at 13:08
  • I use it on an other page of my site and it doesn't load twice
    – ferdi_
    Commented May 11, 2017 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
    Commented May 11, 2017 at 15:12

1 Answer 1

0

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>

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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