ajax button will will not show up

Asked at 2017-01-11 19:24:41Z
  • 5 Subscribers

On one of my pages I have the posts lined up 3 in a row. I want a load more button to appear after every 6 posts. I have set up my code so that it will appear after every 6 posts, but it does not show up at all. Does anyone see the error? Thanks in advance.

Since the button is run through a plugin the only thing I have to add is the div id="ajax" and the closing div and then place the load_more_button(); where I want it.

The plugin is here - https://wordpress.org/plugins/easy-load-more/ However I don't think it has to do with the actual plugin documents because I'm using the load more button on my front page of my site too and it works fine.

get_template_part ('inc/carousel-food');

$the_query = new WP_Query( array(
    'posts_per_page' => 6,
    'paged' => get_query_var('paged', 1),
    'cat' => 10,

if ( $the_query->have_posts() ) {

    // display #ajax wrapper only if we have posts
    echo '<div id="ajax"><div class="row">';
    $i = 0;
    while($the_query->have_posts()) {
          $the_query->the_post(); ?>

                   if($i % 3 == 0) {
                     echo '</div><div class="row">';

                <div class="col-md-4">
                    <article <?php post_class(); ?> >
                        <?php the_post_thumbnail('medium-thumbnail'); ?>
                            <h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                            <p class="post-excerpt"><?php echo get_the_excerpt(); ?></p>
                            <?php get_template_part( 'share-buttons' ); ?>
                            <a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
                            <?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'comment-count', 'none'); ?>

    <?php $i++; }//end while

    echo '</div></div>'; // close the #ajax wrapper after the post list

    if(get_query_var('paged') < $the_query->max_num_pages) {

} else { // if there are no posts

    echo '<p>Sorry, no posts matched your criteria.</p>';

}//end if


0 answers in total

Answer this questsion