URL sync and shareable filters
URL sync uses the same front-end helpers for Archive Loop workflows and Divi 5 Loop Builder targets. Behavior below applies whenever Divi Ajax Filter updates results via AJAX.
Purpose
When visitors change filters, Divi Ajax Filter updates the browser URL with history.replaceState so the address bar reflects the active filter state. Visitors can:
- Copy the URL and share a filtered view
- Bookmark a filtered catalog or archive
- Use the browser back/forward history without losing filter context on reload of that URL
How URL sync works
Filter session flag
The first active filter adds a filter=true query flag (also accepted as 1, yes, or on). That flag tells the script the page is in a filtered session.
Example shape:
https://example.com/shop/?filter=true&product_cat=shoes&min_price=20&max_price=80
Exact parameter names come from each Filter Posts Item (taxonomy slugs, meta keys, price fields, and so on).
Writing parameters
As visitors change filters, the script:
- Collects values from each
.search_filter_contfilter control - Writes or updates matching query parameters
- Removes a parameter when that filter is cleared
- Runs the AJAX filter request so results match the URL
Restoring from a URL
On page load, if the URL includes the filter flag, the script reads query parameters, applies them to matching filter controls (data-name keys), and refreshes the target loop so the UI matches the shared link.
Reset
Clicking Reset clears filter controls and strips the query string back to the page path (no filter parameters), then reloads the unfiltered loop state.
Pagination and sorting in the URL
- Pagination — Page numbers sync into the URL (for example
page,paged, or a custom loop page key). Changing filters resets pagination to page 1. - Sorting — Catalog or loop
orderbyvalues can sync into the URL when visitors change sort controls. - AJAX pagination — When AJAX pagination is enabled, page clicks update the URL and refresh results without a full reload.
See also Pagination preserves filters.
Archive Loop vs Loop Builder
| Results target | URL sync |
|---|---|
| Archive Loop | Filter params and pagination sync through the main Ajax Filter front-end script. |
| Loop Builder | Divi 5 Loop Builder targets use the same URL helper pattern so shared links restore filters and page state. |
Set Target loop (or the Loop Builder equivalent) correctly so the loop that updates is the one visitors see when they open the shared URL.
Practical tips
- Test a shared link in a private window — Confirm filters and results restore without being logged in as an editor.
- Keep post types aligned — Filter Posts and the results loop must query the same post type.
- Avoid conflicting query params — Custom theme or plugin query vars can collide with filter parameter names; rename filter item keys if needed.
- Caching — Aggressive page cache that ignores query strings can serve an unfiltered HTML shell. Exclude filtered URLs or cache AJAX responses carefully. See Caching and performance.
- Select2 / chips — Active selections still sync to the URL; Select2 and filter parameter chips update the UI after restore.
What's Next
- Ajax filter module behavior — Target loop and update timing
- Pagination or Load More loses filters — Fix lost state across pages
- Filter Posts module — Filter parameter display and layout options
- Caching and performance — Cache settings that can affect filtered URLs