Bricks Builder

Mastering Bricks Pagination with AJAX Filters: Solving Duplicate Results

Duplicate posts when you combine AJAX filters with pagination in Bricks Builder almost always come down to a non-unique sort order. Here is the exact fix, and why it works.

Brick builder Blog Post image

Key takeaways

  • Understand why mastering Bricks pagination with AJAX filters: solving duplicate results matters for faster, easier-to-manage WordPress builds, and where it can affect real business results.
  • Review understanding the pagination and filtering issue and breaking down the cause of duplicate pagination results so decisions are based on evidence, not assumptions.
  • Use the guidance as a practical checklist to improve site speed, editor confidence, and long-term maintainability without wasting time on low-impact changes.

The short answer: duplicate results when you page through AJAX-filtered posts in Bricks are almost always caused by a non-unique sort order. When several posts share the same date, WordPress cannot reliably split them across pages, so the same item can appear on both page one and page two. Give the query a unique tie-breaker – sort by date and by post ID – and the duplicates stop. The rest of this guide explains why it happens, and walks through the other fixes if that alone does not settle it.

Introduction

When building dynamic content in WordPress, especially with AJAX filtering, ensuring seamless pagination can be challenging. This guide walks through a real-world example encountered using Bricks Builder, where filtering with AJAX and paginated results led to duplicate entries. We’ll break down why this issue isn’t unique to Bricks and share practical steps to make pagination and AJAX filters work harmoniously across WordPress.

Understanding the Pagination and Filtering Issue

In our use case with Bricks Builder, the pagination and AJAX filters displayed an unexpected behaviour: selecting a filter (e.g., “Widgets”) correctly showed results on multiple pages. However, upon closer inspection, items appeared on both page one and page two, creating confusion for the end-user.

This issue wasn’t isolated to Bricks but was due to how WordPress handles pagination queries, particularly when post timestamps aren’t unique. When WordPress orders content by date, identical timestamps across posts can result in unpredictable pagination, causing items to appear repeatedly across paginated pages.

Here is a video showing the issue. Watch the post titled “Image Widget” you will see duplication occur.

Breaking Down the Cause of Duplicate Pagination Results

The underlying issue is related to how WordPress sorts content in queries. By default, WordPress orders posts by date in descending order, which works well for most scenarios. However, when posts have the same date (as happens frequently with imported content or bulk-created entries), WordPress may struggle to maintain unique pagination, leading to duplication.

In our case:

  • Imported Posts: All imported posts for the “Widgets” filter shared the exact same timestamp, meaning they were indistinguishable by date alone.
  • AJAX and Pagination: With AJAX filtering, WordPress was unable to distinguish results across pages since they lacked unique identifiers in the query.

Solution Steps to Resolve Pagination and Filter Duplication

This solution applies broadly to WordPress sites using AJAX filters, not just Bricks users, but here we’ll illustrate it using Bricks Builder settings.

1. Change the Sorting Order for Uniqueness

  • To avoid repeated posts, use a unique field for sorting—such as Post ID or Title—instead of the default Date.
  • In Bricks: Go to the template query settings and adjust the “Order By” field from Date to Title or Post ID. This change ensures that each post has a unique order, allowing WordPress to manage pagination without duplicating entries.
  • For General WordPress Users: Access the query settings for your filtered content in your theme or plugin and apply a unique sorting order.

2. Disable Query Merge (If Using Complex Query Setups)

  • When dealing with complex queries or layered filters, sometimes query conflicts can occur. In Bricks, leaving the “Disable Query Merge” option off allows the main query to function cleanly.
  • This step is optional, but for those encountering complex filtering requirements, ensure that query settings aren’t overly restrictive.

3. Applying User Interaction Enhancements for Smooth Navigation

  • Using AJAX pagination allows for a smoother user experience, but ensuring that users return to the top of the content after each pagination click improves usability. In Bricks, you can add an Interaction to the block element to scroll to the top automatically after each pagination click.
  • For non-Bricks WordPress setups, a simple JavaScript or jQuery snippet can be added to trigger an automatic scroll back to the top after each pagination action.

4. Additional Considerations for Custom Queries and AJAX Filters

  • If using custom WP_Query calls or plugins to generate your paginated results, ensure your query parameters avoid default ordering by Date if timestamps are the same. For instance, try a combination of Post ID and Title ordering for unique identifiers across each paginated page.
  • AJAX filtering can also sometimes interact with caching plugins in ways that disrupt smooth pagination. If you’re using caching, ensure your AJAX requests bypass caching or are configured for real-time updates.

Summary: Optimising Pagination and Filtering for WordPress

While this example centres around Bricks Builder, the principles here are essential for any WordPress setup involving AJAX filtering and pagination. By setting unique sorting identifiers and configuring interactions correctly, you can achieve reliable and consistent results across paginated content, elevating the user experience and reducing display errors.

This approach allows you to maintain control over how filtered content appears on each page, ensuring smooth transitions and avoiding frustrating duplication. With these insights, you’ll be well-equipped to tackle any similar pagination challenges, no matter your WordPress theme or builder of choice.

Bricks pagination FAQs

Why do I get duplicate posts with Bricks pagination and AJAX filters?

Almost always a non-unique sort order. When posts share the same date, WordPress cannot keep pagination stable, so the same item appears on more than one page. Adding a unique secondary sort, such as post ID, fixes it.

How do I stop duplicate results in Bricks pagination?

Set the query to order by date and then by ID, so every post has a unique position. On complex setups, also turn off query merge and make sure your filter and your query use the same query ID.

Is this a Bricks Builder bug?

No. It is how WordPress paginates posts with tied timestamps, and it can happen with any builder or a custom WP_Query. Bricks simply makes the duplication easy to see.

Will changing the sort order affect my visitors or SEO?

There is no real downside. Adding a tie-breaker such as post ID keeps the order stable and predictable, and visitors just stop seeing the same post twice.

Turn this advice into a better website.

Talk to us about improving your website, search visibility, or marketing performance.

Let's Create
Together
Contact Us