Back to Tips & Tricks

JetEngine Query Results Count Not Updating After Filter: Full Fix

BoostMyCroco TeamPublished on
Filtered listing grid with a live results counter above it, showing a JetEngine count that updates after filtering

If your JetEngine query results count is not updating after a filter, first update JetEngine to 3.8.9.2 or newer. Its changelog lists the fix "Query Results Count macro doesn't update count after filtering". Then check that the Listing Grid and the Query Results Count dynamic tag use the same Query Builder query, and that your filters are connected to that grid.

Below is the Elementor setup for a "Showing 24 results" line that changes when visitors filter. It also covers which count option to pick with pagination, the Counter widget "NaN" problem, and what to check when the number is wrong.

Two different counts in Crocoblock

People often mix up two features:

  • Query Results Count (JetEngine): one number above the grid, such as "Showing 24 results". This is a dynamic tag, and it is what this tip is about.
  • Indexer counters (JetSmartFilters): the small numbers next to each filter option, such as "Apartment (12)". These come from the filter's Indexer. You turn them on with the Apply Indexer and Show Counter toggles in the filter's Indexer Options. See How to Index Filters with Indexer Option.

Also don't use the Query Calculations dynamic tag (sum, average, min, max) for this. Crocoblock states it returns a plain number and can't be updated on AJAX filter requests.

Before you start: update JetEngine

Check your JetEngine version under Plugins. Two releases matter:

  • 3.8.9 added a plain number output option for the Query Results Count dynamic tag.
  • 3.8.9.2 fixed "Query Results Count macro doesn't update count after filtering".

The changelog entry names the macro; it is a likely cause for the dynamic tag too, so update first and test. Both entries are in this mirror of the JetEngine changelog. Update JetSmartFilters at the same time.

Step 1: Build one Query Builder query

The count tag only works with queries made in JetEngine's Query Builder. It counts the query you pick in its settings, so the grid must show results from that exact query.

  1. Go to JetEngine > Query Builder and add a new query (for example, a Posts query for your custom post type).
  2. Set the query arguments you need: post type, status, order and so on.
  3. Open the Pagination tab and set Posts Per Page, for example 12. Set it here, not in the Listing Grid. The Query Pagination value overrides the grid's own posts number (5 in the query and 6 in the grid gives 5 per page), and the count tag only works with the Query Pagination settings.
  4. Save the query.
  5. In Elementor, select the Listing Grid widget, turn on Use custom query and pick your query in the Custom Query dropdown. Don't rely on the grid's own query settings.

If Query Builder is new to you, our list of JetEngine Query Builder mistakes and fixes covers the usual traps.

Step 2: Connect JetSmartFilters to the grid

The count can only change if the filters actually change the grid.

  1. Go to Smart Filters > Settings and, in the General Settings, make sure the JetEngine provider is enabled. Otherwise JetEngine won't appear as an option in the filter widgets.
  2. Add your filter widgets (Checkboxes, Select, Range, Search and so on) to the page.
  3. In each filter widget, set This filter for to JetEngine.
  4. Set a Query ID. Filters can work without one, but Crocoblock notes it is often required when the grid uses a Query Builder query or the page has several grids. Use the same ID (for example directory) in three places:
    • the Query ID field of each filter widget;
    • the Listing Grid's Advanced tab, in the CSS ID field (the grid has no Query ID field of its own);
    • the Query ID field in the Query Builder query's settings.
  5. Pick an Apply Type: AJAX updates the grid without a page reload; Mixed and Page Reload are the other options.
  6. Open the page on the front end and use a filter. The grid should change before you go further.

Crocoblock's guide How to Use Filters with Listing Grid covers this connection in detail. For a complete filtered directory, see our real estate property search filter tip.

Step 3: Add the Query Results Count tag

  1. Drag a Heading widget above the Listing Grid.
  2. Click the Dynamic Tags button in the Title field and choose Query Results Count.
  3. Click the tag to open its settings. In Query, pick the same query the grid uses.
  4. In Returned Count, choose Total query results count for "X results found".
  5. Open the Advanced tab. Set Before to Showing and After to results (mind the spaces). Optionally add a Fallback text, shown when the count can't be displayed.
  6. Update the page, then apply a filter on the front end. The number should change with the grid.

Always test on the front end. The Elementor editor preview doesn't behave like the live page (the Pagination widget, for example, always shows 10 pages in the editor).

By default the tag outputs the number inside a span. Example output:

<span class="jet-engine-query-count query-92 count-type-total" data-query="92">0</span>

The query-92 class, data-query="92" and the 0 are placeholders that depend on your query ID and the actual result, so target only the jet-engine-query-count class.

To style the number, give the Heading a class under Advanced > CSS Classes, for example results-count, and add this CSS to your child theme stylesheet or custom CSS area:

.results-count .jet-engine-query-count {
  font-weight: 700;
  color: #0f766e;
}

This selector matches the default HTML output only, not plain number output or Custom format. Inspect the number in your browser's dev tools to confirm the span is there.

Total, visible or custom format

The Returned Count setting has three options:

OptionWhat it showsUse it for
Total query results countAll matching results across all pages"24 results found"
Currently visible query results count (per page)Only the results on the current page"12 results on this page"
Custom format for several countersA Format field where you combine counts with macros"Showing 12 of 24 results" in one tag

Without pagination, total and visible are the same number. With pagination, the visible count follows Posts Per Page in the query's Pagination tab, which is why the grid's own posts number is ignored. Crocoblock's tutorial lists the Pagination tab for Posts, Comments and WC Product queries. For other query types (CCT, Users, SQL), check whether your JetEngine version has a Pagination tab before relying on the visible count.

Showing "12 of 24 results"

Choose Custom format for several counters. Its Format field takes macros in the form %query_count|ID|total% and %query_count|ID|visible%, where ID is your query's ID. A starting point:

Showing %query_count|ID|visible% of %query_count|ID|total% results

Replace both IDs with your query's ID. Check the Dynamic Tags Overview and the JetEngine Macros Guide for the exact format, then apply a filter on the front end and confirm both numbers change.

If the custom format doesn't suit your layout, place two Heading widgets side by side, for example in a container with Direction set to Row, each with one Query Results Count tag:

  1. First Heading: Currently visible query results count (per page), Before Showing (trailing space), After of (leading space).
  2. Second Heading: Total query results count, After results (leading space).
  3. Pick the same query in both.

The spaces next to each number sit inside its Heading, so they render. Set a small Gap on the container to add the space between the two Headings, then check the rendered line on the front end.

Elementor Counter widget shows NaN

If you put the tag in the Ending Number of Elementor's Counter widget, you get "NaN" and no animation. The Counter widget expects a bare number, and the tag sends the HTML span.

  • JetEngine 3.8.9 and newer: that release added a plain number output option for the Query Results Count tag. Look for it in the tag's settings in your version and switch it on.
  • Older versions: update JetEngine. If you can't, the GitHub issue about raw numeric output links a free add-on and a CodeLab snippet that output a plain number.

On filtered pages, test carefully. Plain number output has no span with a data-query attribute, and it is not confirmed that a plain number refreshes after AJAX filtering. The Counter may be right on page load and then stay the same when visitors filter. For a live "X results found" line, the Heading widget with the default output is the safer choice.

Count still wrong? Troubleshooting checklist

The count does not change after filtering

Likely cause: JetEngine older than 3.8.9.2. That changelog entry names the macro; it is a likely cause for the dynamic tag too. Fix: update JetEngine, clear any page cache, and test on the front end. If that doesn't help, check that the Query ID matches in the filters, the grid's CSS ID and the query's settings, and that the grid and the tag use the same query. If you switched to plain number output, switch back to the default and test again.

The count shows every post, or a different number than the grid

Cause: the tag counts the query picked in its Query setting. If the grid uses its own query settings or a different Query Builder query, they don't match. Fix: select the same Query Builder query in the grid's Custom Query and in the tag.

The filters don't change the grid at all

Then the count can't change either. Recheck Step 2: the provider, This filter for and the Query ID. If the whole page reloads instead of updating, check the filter's Apply Type and the grid's AJAX settings. Our Jet filter issue note covers another case where filters seem dead.

The per-page (visible) count is wrong

Cause: posts per page was set in the Listing Grid. Fix: set Posts Per Page in Query Builder > Pagination and save.

The numbers next to filter options show 0

This is the Indexer, not the Query Results Count. A user report on GitHub describes Indexer counters showing 0 while filtering still works when the Listing Grid has Lazy Load turned on. Update JetEngine and JetSmartFilters first; if the counters still show 0, turning Lazy Load off on that grid is a workaround to test.

The numbers next to filter options don't appear or don't change

Turn on Apply Indexer and Show Counter in the filter's Indexer Options, and check the Change Counters setting, which controls whether counters change when filters are applied. The Indexer works with Checkboxes, Select, Visual, Check Range and Radio filters.

Once the grid and the tag share one query and the filters reach that grid, the count follows every filter change. If you'd rather have someone build or fix your filtered directory, post a request on BoostMyCroco.

Frequently Asked Questions

Why does my JetEngine results count stay at the same number when I filter?
One likely cause is a JetEngine version older than 3.8.9.2, whose changelog fixed "Query Results Count macro doesn't update count after filtering". The entry names the macro, but it is a likely cause for the dynamic tag too, so update first and test. If that doesn't help, confirm the tag and the Listing Grid use the same Query Builder query, that the Query ID matches, and that the filters actually change the grid.
Can I show a results count with Elementor's Loop Grid and JetSmartFilters?
Users have asked Crocoblock for a results-count widget for Elementor's Posts and Loop Grid widgets, and the answer was that this is a JetEngine function. The Query Results Count dynamic tag works with JetEngine Query Builder queries, so use a JetEngine Listing Grid with a Query Builder query for a count that follows the filters.
How do I show Showing 12 of 48 results with JetEngine?
Set Posts Per Page in the query's Pagination tab, choose Custom format for several counters in the tag, and combine the visible and total macros in its Format field. Test it on the front end with a filter applied. Two Heading widgets side by side, each with one count, also work.
Why are the numbers next to my filter options different from the results count?
They are separate features. The numbers next to filter options come from the JetSmartFilters Indexer and show how many items match each option. The Query Results Count shows how many items the grid's query returns in total or on the current page.
Does the Query Calculations tag update after filtering?
No. Crocoblock states that the Query Calculations dynamic tag returns a plain number and can't be updated on AJAX filter requests. For a count that follows the filters, use Query Results Count instead.

This guide answers a question from our community: filter query results not count

Sources

  1. How to Index Filters with Indexer Option — JetSmartFilters (crocoblock.com)
  2. JupiterX (my.artbees.net)
  3. How to Use Filters with Listing Grid — JetSmartFilters (crocoblock.com)
  4. Dynamic Tags Overview — JetEngine (crocoblock.com)
  5. Macros Guide — JetEngine (crocoblock.com)
  6. Jet Engine: Query Results Count should support raw numeric output (no HTML) · Issue #8364 · Crocoblock/suggestions · GitHub (github.com)
  7. Indexer counters show 0 when Listing Grid “Lazy Load” is enabled. Filtering itself works · Issue #8632 · Crocoblock/suggestions · GitHub (github.com)
  8. Query Results Count Dynamic Tag Guide — JetEngine (crocoblock.com)
  9. JetSmart Filters : Result Count not Available · Issue #1558 · Crocoblock/suggestions · GitHub (github.com)
  10. [Jetsmart filters] - result count widget · Issue #6969 · Crocoblock/suggestions · GitHub (github.com)
  11. Visual Filter Overview — JetSmartFilters (crocoblock.com)
  12. JetSmartFilters Overview (crocoblock.com)

Related tips