• Trying to use ALM to load excerpts of up to 11 posts on my home page. Should be 7 that appear on page load, then 4 more load when you scroll to the bottom. Right now ALM seems to be loading all 11 as one post, so using offset=”7″ in this case does nothing. On top of that, the posts that do load are not even the most recent, but older.

    Here is the relevant code from the home page, with shortcode:

    <div id="scroll-container">
       <?php 
          echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="11" category__not_in="11,16,17,18,20,21,22" offset="7" scroll_container="#scroll-container" transition="fade" destroy_after="11" orderby="date" order="DESC"]');
       ?>
    </div>

    And here is my Repeater Template (each post within its own Bootstrap panel):

    <div class="panel panel-info home-load-panel">
      <div class="panel-heading">
        <div class="panel-title">
          <div class="label label-primary"><?php foreach((get_the_category()) as $category) { echo strtoupper($category->cat_name); } ?></div>
            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    	  <small><?php
    	     foreach( (get_the_category() ) as $category) {
    		  if ($category->term_id == 6) {
    		     echo 'by ' . get_the_author();
    		  }
    	     }
    	  ?></small>
          </div>
        </div>
        <div class="panel-body alignleft">
    	<?php
    	  if ( has_post_thumbnail() ) {
    	    the_post_thumbnail(
    		'small', array(
    		   'align' => 'left',
    		   'style' => 'padding-right:7px',
                       'class' => 'img-responsive'
    		)
    	     );
    	   }
    	  the_excerpt();
    	?>
    
    	<p class="pull-right">
    	   <?php
    		foreach((get_the_category()) as $category) {
    		  if ($category->term_id == 1) {
    		     $get_btn_language = 'the full story';
    		  }
    		   elseif ($category->term_id == 6) {
    		     $get_btn_language = 'the blog post';
    		  }
    		   else {
    		     $get_btn_language = 'more';
    		  }
    	        }
    	   ?>
    	   <a href="<?php the_permalink(); ?>" class="btn btn-primary">Read <?php echo $get_btn_language; ?> <i class="fa fa-long-arrow-right"></i></a>
    	</p>
      </div>
    </div>

    Is there a way to get ALM to recognize each panel/post as a single post and not just one post consisting of 11 items?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @jhonn0,
    Without actually viewing the site it sounds like you may be loading Ajax Load More inside the previous loop?

    Is there anyway you could share a link so I can have a look at the issue?

    Thread Starter jhonn0

    (@jhonn0)

    Thanks for your attention — I’ve been testing this only locally so far, but will try to get it up on a dev server this evening.

    However, I did remove the previous loop from the code. Funny enough, while trying things out, I included the previous WP loop in both the page code and the ALM Repeater Template to see what would happen. It still loaded all 11 panels as 1 post, but they were the correct/most current posts.

    Plugin Author Darren Cooney

    (@dcooney)

    Hi @jhonn0,
    Not sure what’s going on then… Hopefully will be able to get the site up on dev so I can review.
    If you dont want to post the link here you can open a support ticket.
    https://connekthq.com/plugins/ajax-load-more/support/

    Cheers,

    Thread Starter jhonn0

    (@jhonn0)

    Apologies for the delay; the page can be found here.

    Hope it can help. It is still loading the wrong group of posts, and all 11 at once — only 7 should load when the page loads, and 4 more when you scroll to the bottom.

    I did notice that some functionality improved when in Settings I changed from Infinite Scroll to a “Load more” button, in that clicking the button did load more posts every time you click it, but that seems to disregard that the shortcode has an offset=7 and posts_per_page=11.

    Thanks

    Plugin Author Darren Cooney

    (@dcooney)

    Hi @jhonn0,
    No worries.
    When I inspect the page i can see posts_per_page is set to 11 and being ordered by DATE DESC.

    I didn’t notice your initial post but your shortcode should be the following.

     echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="7" category__not_in="11,16,17,18,20,21,22" offset="7" scroll_container="#scroll-container" transition="fade" destroy_after="2" orderby="date" order="DESC"]');
    

    Load 7 posts per page and destroy ALM after page #2.

    Let me know if this helps.

    Thread Starter jhonn0

    (@jhonn0)

    Thank you, this was a big help.
    The catch is that the additional posts do not load via infinite scroll, only with a load-more button; the main problem there is that when the page loads, before the posts load you see that button just sitting there at the top. See here

    Is there anything I should look out for to change that?

    Otherwise, I misunderstood the use of offset… by removing it I was able to load the correct/most recent posts.

    Plugin Author Darren Cooney

    (@dcooney)

    Right, for this you have two options.

    You could create a custom query that runs before ALM or you could use the Preloaded add-on which loads posts before ALM and allows you to change the amount loaded.

    Hope this solves that for you πŸ™‚

    Thread Starter jhonn0

    (@jhonn0)

    Got it! But just to be clear, does it sound like an error that the infinite scroll feature isn’t working but the button does? Or is that part of what Preloaded would be for?

    Plugin Author Darren Cooney

    (@dcooney)

    No error. It’s not working because you have display: none; on the load more button which is the trigger.

    Also try setting scroll_distance="0" in your shortcode.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Multiple posts load as one post, in wrong order’ is closed to new replies.