Hi Dan,
Sounds like Ajax Load More is not actually loading on your blog page.
Did you replace your blog template with the shortcode?
Yes, I have this code appearing at the bottom of my index.php file in the root of my theme:
<?php echo do_shortcode(‘[ajax_load_more post_type=”post” post_format=”standard” pause=”true” scroll=”false” button_label=”Load More Posts” button_loading_label=”Loading More Posts…”]’); ?>
Is there another step that I am missing? For example, maybe a function that’s required on the page before that?
Your shortcode is not on that page?
It is in the template file for that page, though. It’s just not displaying (perhaps because I set the # of wordpress posts to show to only 3).Do I need to do anything else in addition to the code above that echoes the shortcode?
WHere did you add the shortcode?
It cannot be within your post loop.
Please post your entire template
<?php get_header(); ?>
<!--Masthead-->
<section id="top" class="masthead">
<div class="container">
<div class="row">
<div class="header col-md-8 col-sm-12">
<h1>The Blog</h1>
<h4>Welcome to our blog; the place where thoughts and musings from KDG come to make themselves known. Whether business woman, volunteer coordinator, or university dean, there is something here for everyone.</h4>
</div><!--col-xs-12-->
</div><!--row-->
</div><!--container-->
<div class="color-overlay"></div>
</section><!--masthead-->
<!---Page Content-->
<section class="blog-bar">
<div class="container">
<div class="row">
<div class="filter-results col-sm-3 col-xs-7">
<a class="dropdown-toggle" data-toggle="dropdown">Most Recent <span class="fa fa-angle-down"></span></a>
<ul class="dropdown-menu">
<?php
$args = array(
'title_li' => __(''),
);
wp_list_categories($args);
?>
</ul>
</div><!--col-->
<div class="view-all-link col-sm-3 col-xs-5">
<!--<a href="blog-archive.html" class="text-link">View All Posts</a>-->
</div><!--col-->
<div class="search-bar col-sm-offset-2 col-sm-4 col-xs-12">
<?php get_search_form(); ?>
</div><!--col-->
</div><!--row-->
</div><!--container-->
</section>
<section class="blog-roll">
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1 col-sm-12">
<?php if ( have_posts() ) : ?>
<?php
// Start the loop.
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
// End the loop.
endwhile;
// Previous/next page navigation.
the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'kdgblog' ),
'next_text' => __( 'Next page', 'kdgblog' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'kdgblog' ) . ' </span>',
) );
// If no content, include the "No posts found" template.
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</div><!--col-->
<div class="col-xs-12">
<!--<a class="kdg-btn centered">Load More Posts</a>-->
<?php echo do_shortcode('[ajax_load_more post_type="post" post_format="standard" pause="true" scroll="false" button_label="Load More Posts" button_loading_label="Loading More Posts..."]'); ?>
</div>
</div><!--row-->
</div><!--container-->
</section>
<?php get_footer(); ?>
Ok thanks.
Yes, the ALM JS is not being loaded. Please confirm you have wp_footer() in your footer.php file.
As well, the CSS is not being loaded. You need wp_head() in your site headr
Thanks dcooney…I believe that is the issue. I am trying to use parent files from the root of the site for the header and the footer, so I will need to work in a way to include those. I’ll let you know if that solves the issue.
-Dan
Ok, almost there! I found a way to put the wp_head and wp_footer functions into my header and footer appropriately. If you check that page URL again and click the button, it reloads some of the same posts. How do I prevent it from doing that? There should be 5 posts total, not 8.
Thanks!
Dan
Set the offset in your shortcode to 3. offset=”3″.