• Resolved Phillip Dews

    (@phillipdewsblogger)


    Hi All,

    I have an unusual one here. I wish to use this plugin to load more posts after the first 12. To give you some idea here is my very custom loop.php page…

    <div id="column_01">
        <!-- First Loop: Display post 1 -->
        <?php query_posts('showposts=2'); ?>
        <?php $posts = get_posts('numberposts=2&offset=0'); foreach ($posts as $post) : start_wp(); ?>
        <?php static $count1 = 0; if ($count1 == "2") {break;} else { ?>
          <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <a href="<?php the_permalink(); ?>">
              <div class="the-title">
                <h2>
                  <?php the_title(); ?>
                </h2>
              </div>
              <div class="img-container">
                <figure>
                  <!-- The Post Thumbnail -->
                  <?php if(has_post_thumbnail()) : ?>
                    <?php the_post_thumbnail('bloglanding-post-thumbnail'); ?>
                  <?php endif; ?>
                </figure>
              </div>
            </a>
            <div class="socialWarf"><?php social_warfare(); ?></div>
          </article>
        <?php $count1++; } ?>
        <?php endforeach; ?>
      </div>

    After this first Column I have a further 3 more showing the latest 12 posts. After that I want to rest using this plugin. The repeater template I tries to use this this…..

    <?php query_posts('showposts=6'); ?>
        <?php $posts = get_posts('numberposts=6&offset=12'); foreach ($posts as $post) : start_wp(); ?>
        <?php static $count5 = 0; if ($count5 == "6") {break;} else { ?>
    <article id="post-mainblock" <?php post_class(); ?>>
    	<a href="<?php the_permalink(); ?>">
    		<div class="the-title">
    			<h2>
    				<?php the_title(); ?>
    			</h2>
    		</div>
    	<div class="img-container">
    		<figure>
    			<!-- The Post Thumbnail -->
    			<?php if(has_post_thumbnail()) : ?>
    			<?php the_post_thumbnail('bloglanding-post-thumbnail'); ?>
    			<?php endif; ?>
    		</figure>
    </div>
    </a>
    </article>
        <?php $count5++; } ?>
        <?php endforeach; ?>

    As you can see from the page it is showing a lot more than the first 6 posts it should be showing. Remember the are 4 columns showing the latest 12 and at the time of writing this there are 18 test posts published starting with the usual Hello World post.

    I hope all this makes sense!
    Many thanks,

    Phillip Dews

    • This topic was modified 3 years, 7 months ago by Phillip Dews. Reason: Finishing off my post

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Phillip Dews

    (@phillipdewsblogger)

    Oops it should say “Display Posts after the First 12”

    Plugin Author Darren Cooney

    (@dcooney)

    @phillipdewsblogger Ajax Load More creates its own query and you shouldnt be doing this in your Repeater Template.

    Have you seen my Implementation Guide
    https://connekthq.com/plugins/ajax-load-more/docs/implementation-guide/

    Or the Repeater Template docs
    https://connekthq.com/plugins/ajax-load-more/docs/repeater-templates/

    All you may need to do is set offset=“12”in your shortcode to get this working.

    Thread Starter Phillip Dews

    (@phillipdewsblogger)

    @dcooney Thank you for that, However its still not working.
    At the bottom of my loop.php file I now have this….

    <?php echo do_shortcode('[ajax_load_more container_type="div" offset=“12”]'); ?>

    for my repeater template I have this….

    <article id="post-mainblock" <?php post_class(); ?>>
    <a href="<?php the_permalink(); ?>">
    <div class="img-container">
    <figure>
    <!-- The Post Thumbnail -->
    <?php if(has_post_thumbnail()) : ?>
    <?php the_post_thumbnail('bloglanding-post-thumbnail'); ?>
    <?php endif; ?>
    </figure>
    </div>
    <div class="the-title">
    <h2>
    <?php the_title(); ?>
    </h2>
    </div>
    </a>
    <div class="socialWarf"><?php social_warfare(); ?></div>
    </article>

    However if you look HERE you will see the load more button at the bottom after Testing Post 7 and no more posts showing or loading buddy.

    Many thanks,
    Phillip Dews

    Plugin Author Darren Cooney

    (@dcooney)

    @phillipdewsblogger You’re ajax request is returning a 500 error.
    This is likely a PHP error in your Repeater Template.

    I’d suggest checking your site error_log to see exactly what the issue is or share the template again, here.

    Thread Starter Phillip Dews

    (@phillipdewsblogger)

    Hi @dcooney,

    There are no Error Logs at all showing. I have now reverted to the default repeater template in your plugin and its still the same issue fella.

    This is the one I’m using….

    <li class="alm-item<?php if (! has_post_thumbnail() ) { echo ' no-img'; } ?>">
       <?php if ( has_post_thumbnail() ) {
          the_post_thumbnail('alm-thumbnail');
       }?>
       <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(); ?>
    </li>

    It’s not the repeater template itself. it’s your suggestion. Before I had this in my loop.php file…

    <?php echo do_shortcode('[ajax_load_more offset=“12”]'); ?>

    However when I take out the offset so its like this….

    <?php echo do_shortcode('[ajax_load_more]'); ?>

    It works perfectly

    Many thanks,
    Phillip

    • This reply was modified 3 years, 7 months ago by Phillip Dews. Reason: Update
    Thread Starter Phillip Dews

    (@phillipdewsblogger)

    Looks like I fixed it with this….

    <?php echo do_shortcode('[ajax_load_more post_type="post" offset="12"]'); ?>

    All good now. Hopefully this will help others. Thanks for your insights @dcooney

    Phillip

    Plugin Author Darren Cooney

    (@dcooney)

    Nice, thanks for following up.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Dispal Posts after the first 12’ is closed to new replies.