• Resolved pauti12

    (@pauti12)


    Hello,
    I am having some problems with the plugin…
    I have created a new repeater template, but when the “load more” button is clicked, it displays the same posts 5 times…
    What it should do is display 5 posts, but instead is displaying 5 different posts 5 times…

    This is my Shortcode:

    <?php echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="6" pause="true" offset="7" scroll="false" button_label="Load more"]'); ?>

    This is my Repeater template:

    <?php 
    
    $loop_one = array( 
    	'category_name'  => 'article',
    	'posts_per_page' => 4,
        'orderby' => 'post__in'
    );
    
    $query_one = new WP_Query( $loop_one ); ?>
        <?php if ( $query_one->have_posts() ) :
            while ( $query_one->have_posts() ) : $query_one->the_post(); ?>
                
                <?php if (has_post_thumbnail()) {
         			the_post_thumbnail(array(150,150)); } ?>
    			<h3>
        			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    			</h3>
    			<p class="entry-meta">
        			<?php the_time("F d, Y"); ?>
    			</p>
    			<?php the_excerpt(); ?>
    			
        <?php endwhile; ?>
    		<?php wp_reset_postdata(); ?>
    
    	<?php else : ?>
    		<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    	<?php endif; ?>

    EDITED:

    I’ve changed the shortcode to posts_per_page=”1″ and that solve the problem of repeating the posts 6 times. So now, when I click “Load more” it displays 4 posts, but when I click again to see more posts, it displays the same 4 posts… Any idea why?

    • This topic was modified 7 years, 10 months ago by pauti12.
Viewing 1 replies (of 1 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @pauti12,
    You repeater template has a wordpress loop in it. Ajax Load More handles the loop by adjusting the shortcode parameters.

    Your template should look like as simple as this.

    <article>
    	<?php if (has_post_thumbnail()) {
    		the_post_thumbnail(array(150,150)); 
    	} ?>
    	<h3>
    		<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    	</h3>
    	<p class="entry-meta">
    		<?php the_time("F d, Y"); ?>
    	</p>
    	<?php the_excerpt(); ?>
    </article>

    Hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Repeating posts 5 times on “Load more”’ is closed to new replies.