How to Make a WordPress AJAX Load More Blog Crawlable
A custom blog archive shows six articles and a Load More button. Visitors click it and see the next six, so the feature seems complete. But what happens when someone requests the second archive page directly, or JavaScript fails before the click handler attaches?
Build a working paginated archive first. Then let JavaScript improve the experience by appending the next page’s articles without a full navigation.
A button is not a link to the next page
Google generally discovers links through anchor elements with href attributes. Its crawlers do not normally click Load More buttons to reveal additional results. Google recommends distinct pagination URLs and sequential links between pages. Google’s pagination guidance
A sitemap offers another discovery route, but your archive should still provide a usable path to older articles. A reader should not need a search engine to reach posts beyond the first batch.
Start with the WordPress archive query
For a classic PHP theme using the normal posts archive, render the main query and its pagination together. This example belongs in the relevant archive template, such as home.php for the posts index:
<?php if ( have_posts() ) : ?>
<div class="blog-results" data-blog-results>
<?php while ( have_posts() ) : the_post(); ?>
<article>
<h2>
<a href="<?php echo esc_url( get_permalink() ); ?>">
<?php the_title(); ?>
</a>
</h2>
<?php the_excerpt(); ?>
</article>
<?php endwhile; ?>
</div>
<?php
the_posts_pagination(
array(
'mid_size' => 1,
'prev_text' => __( 'Previous', 'martincv' ),
'next_text' => __( 'Next', 'martincv' ),
)
);
?>
<?php else : ?>
<p><?php esc_html_e( 'No posts found.', 'martincv' ); ?></p>
<?php endif; ?>
Replace the translation domain with your theme’s domain. This is an illustrative template fragment, not a complete theme file or a block-theme implementation. Use your existing card markup around the same loop. WordPress provides the pagination wrapper used here through the_posts_pagination().
A custom query needs its own current-page value and total page count. Pass the appropriate paged value into WP_Query; account for the different page variable when working on a static front page. Do not accidentally build pagination from the unrelated main query. WP_Query pagination parameters
When constructing links manually, paginate_links() supports explicit current-page and total-page values. paginate_links() reference
Enhance the next-page link
Once normal navigation works, JavaScript can intercept an ordinary click on Next. Fetch that link’s URL, extract the next batch of cards from the returned HTML, append them, and update the next-page URL.
Using the rendered archive as the source reduces the chance that the AJAX version and the directly requested page use different ordering or templates.
Keep modified clicks working so visitors can open the link in another tab. During loading, prevent duplicate requests and show a loading state. If fetching or parsing fails, restore normal navigation rather than leaving a dead control. Announce the number of added results for assistive technology without unexpectedly moving keyboard focus.
Keep each page’s identity clear
Use real URLs such as /blog/page/2/, not fragment-only states such as #page-2. Each paginated page should identify itself as canonical rather than canonicalizing all archive pages to page one. Google’s pagination guidance
Decide separately how category filters and searches work. If changing a category starts a new result set, reset pagination with it. Avoid retaining a page number that no longer exists in the selected category.
Verify navigation before checking rankings
Open page two directly in a fresh tab. Check that it returns the expected posts and that its links work without JavaScript. Then test the enhanced version for duplicate cards, missing cards, a failed request, and the final page.
Also compare the source HTML with the browser-rendered page. The links to articles and subsequent archive pages should already exist in the server response.
Crawlable pagination improves discovery and navigation; it does not guarantee indexing or rankings. Once the archive works, the next question is whether each linked article gives readers a useful answer.
If your custom archive needs both frontend and WordPress query work, see my custom development service.
Enjoyed this article?
Check out more articles on web development, WordPress, and modern technologies.
View All Articles