Repository navigation
Blocks Query Filter
Block name: designsetgo/query-filter
Added in: 2.1.0
Category: DesignSetGo
Block family: Query (parent) · Query Results · Query Pagination · Query Filter · Query Group Header · No Results
The Query Filter block adds interactive filtering controls to a Dynamic Query. One block instance renders one filter control. Insert multiple Query Filter blocks — one for each filter dimension you need — at any position within the Query block's tree.
The block has six variations (filterKind). All of them work by updating URL parameters and triggering an Interactivity API refresh, so the results update without a full page reload. When JavaScript is unavailable, every filter falls back to a <form method="get"> submission that reloads the page with the updated URL.
Filter state is reflected in the URL so filtered views are shareable and indexed.
| Attribute | Type | Default | Notes |
|---|---|---|---|
filterKind |
string | "checkbox" |
checkbox | select | search | sort | active | reset
|
taxonomy |
string | "category" |
Taxonomy slug; used by checkbox and select kinds |
paramName |
string | "filter_category" |
URL parameter name this filter reads and writes |
label |
string | "" |
Visible label, legend, or button text |
placeholder |
string | "" |
Input placeholder; used by search kind |
sortOptions |
array | [Newest, Oldest, A–Z, Z–A] |
Option definitions for the sort kind; each entry has value and label
|
showCounts |
boolean | true |
Append (N) counts to checkbox and select options |
orientation |
string | "vertical" |
vertical | horizontal — checkbox list layout |
filterStyle |
string | "default" |
default | pill | underline — visual style of checkbox items |
Renders a <fieldset> + <legend> with one checkbox per term in the taxonomy. Supports multi-value selection: checking multiple terms adds each value to the paramName[] URL array. Unchecked checkboxes are always visible so users can see all available options.
Per-option counts — when showCounts is true and the filter has been indexed, each term label includes a (N) count showing how many results match. Counts are intersection-aware: they reflect the number of results that match this term combined with all currently active filters across other dimensions, not just the term in isolation.
Orientation — vertical (default) or horizontal row. The pill and underline styles automatically switch to horizontal.
Style variants:
-
default— standard checkboxes with visible controls -
pill— native checkbox hidden; label styled as a pill button -
underline— native checkbox hidden; label styled as an underlined tab
All style variants keep the <input type="checkbox"> in the DOM so keyboard users and screen readers toggle filters the same way.
A <select> dropdown with one option per term plus a "All" default. Single-value: selecting a term sets ?paramName=slug; selecting "All" removes the parameter. Supports per-option counts from the filter index.
A text input with a submit button. The search value sets ?paramName=value. Submitting with an empty field removes the parameter. The query's bindSearchTo attribute on the parent Dynamic Query block can point to the same parameter so the search term drives the query's full-text search.
Default input role is search; the wrapper <form> carries role="search".
A <select> dropdown for changing result order. Each option value is a field.DIRECTION string (e.g. date.DESC, title.ASC). The parent query reads the sort URL parameter and splits it into orderBy and order at render time.
Default sort options provided by the block:
- Newest (
date.DESC) - Oldest (
date.ASC) - A–Z (
title.ASC) - Z–A (
title.DESC)
Custom sort options can be defined in the Inspector.
Renders a strip of "chip" links showing each currently active filter value. Clicking a chip removes that one filter from the URL. Each chip is an <a href="…"> whose href pre-encodes the removal URL — the no-JS fallback navigates to that URL directly.
Only renders when at least one filter parameter (filter_*, q, or sort) is present in the URL. Renders nothing when no filters are active.
Renders a single button link that navigates to the current URL with all filter parameters (filter_*, q, sort, paged, page) removed. The button is an <a href="…"> for no-JS fallback.
Filter kind — select control for the six variations.
Taxonomy — visible for checkbox and select; taxonomy slug the filter operates on.
URL parameter name — the paramName this block reads from and writes to the URL.
Label — optional visible label. For checkbox it becomes the <legend> text. For search it becomes a <label> linked to the input. For reset it overrides the button text.
Placeholder — visible for search; input placeholder.
Sort options — visible for sort; repeatable list of option label/value pairs.
Show counts — toggle for checkbox and select; requires the filter to be indexed.
Orientation — toggle for checkbox; switches between vertical list and horizontal row.
Per-option counts are powered by the {$wpdb->prefix}dsgo_query_filter_index table, which is maintained automatically on save_post, taxonomy change, and meta change events. The index stores one row per post × filter-option combination, enabling fast intersection-aware count queries.
For counts to appear, a filter must be registered. Filters are registered automatically when a Query Filter block is saved; they can also be registered programmatically via the designsetgo_query_registered_filters filter.
The filter index can be rebuilt from Settings → DesignSetGo → Dynamic Query or via WP-CLI:
wp dsgo query index rebuild
wp dsgo query index rebuild-filter <filter_key>
wp dsgo query index status
On every filter interaction, the Interactivity API store:
- Builds a new URL by updating the relevant parameter
- Strips both
pagedandpageparameters (resets to page 1) - Posts to
POST /designsetgo/v1/query/renderwith the new URL - Swaps the entire
dsgo-query-regionelement'sinnerHTML— this updates the item grid, pagination, no-results block, and active-filter chips in one operation - Calls
history.replaceStateto update the browser URL without a page reload
Post-swap DOM handling: after a refresh, the DOM inside the region is replaced with server-rendered HTML. The Interactivity API's directive bindings no longer fire on replaced elements. A document-level delegated event listener handles all subsequent filter interactions on the swapped DOM, preventing silent no-ops.
- All filter forms wrap in
<form method="get">for no-JS fallback -
prefers-reduced-motionhas no special handling for filters (motion is limited to item list swaps which don't animate) - Counts update with every filter change to reflect the new intersection state
- The filter block renders even if its taxonomy has no terms (for
checkbox/select); the block simply outputs nothing in that case
-
checkboxvariation: terms are wrapped in<label>elements; multiple checkboxes are grouped in<fieldset>+<legend>when a label is provided -
searchvariation:<form role="search">; input has an explicit<label>oraria-label="Search" -
sortvariation:<select>has an explicit<label>oraria-label="Sort" - Active filter chips: each chip is an
<a role="button">with a screen-reader-only "Remove category: value" label - Count badges are plain text appended to the option label; no separate
aria-labelis needed - No-JS submit button inside
<noscript>ensures progressive enhancement for checkbox and select forms
- Dynamic Query — the parent container block
- Query Results — the item grid that gets refreshed
- Query Pagination — pagination resets automatically on filter change
- No Results — shown when filters produce zero results
Auto-generated from
docs/blocks/QUERY-FILTER.md. To update, edit the source file and changes will sync on next push to main.
- Accordion
- Advanced Heading
- Blobs
- Breadcrumbs
- Card
- Chart
- Comparison Table
- Countdown Timer
- Counter Group
- Divider
- Dynamic Image
- Fifty Fifty
- Flip Card
- Form Builder
- Grid
- Hotspot
- Icon
- Icon Button
- Icon List
- Image Accordion
- Map
- Modal
- Modal Api Reference
- Modal Auto Triggers
- Modal Fse Compatibility
- Modal Gallery Navigation
- Modal Trigger
- Pill
- Product Categories Grid
- Product Showcase Hero
- Progress Bar
- Query
- Query Filter
- Query Group Header
- Query No Results
- Query Pagination
- Query Results
- Row
- Scroll Accordion
- Scroll Marquee
- Scroll Slides
- Section
- Section Divider
- Slider
- Star Rating
- Sticky Sections
- Table Of Contents
- Tabs
- Text Path
- Timeline
- Background Video
- Block Animations
- Clickable Group
- Conditional Visibility
- Custom Css
- Draft Mode
- Dynamic Tags
- Expanding Background
- Grid Mobile Order
- Grid Span
- Hover Effects
- Max Width
- Responsive Visibility
- Reveal Control
- Scroll Parallax
- Sticky Header
- Style Binding
- Svg Patterns
- Text Alignment Inheritance
- Text Reveal
- Abilities Api
- Abilities Api Guide
- Block Bindings
- Draft Mode Api
- Form Webhooks
- Generation Contract
- Interactive Blocks
- Layout Flexibility
- Markdown Content Negotiation
- Rest Api Reference
- Wp Cli Reference
- Ai Assisted Development
- Best Practices Summary
- Block Controls Organization
- Block Development Best Practices Comprehensive
- Block Exclusion Guide
- Deploying To Wordpress Org
- Design System
- 2026 04 16 Blocks Editor Ux Design
- 2026 04 17 Theme 3 Inspector Ia
- 2026 04 21 Query Block Onboarding
- 2026 04 21 Query Capable Layout Blocks Design
- 2026 04 27 Block Roadmap Ideas
- 2026 07 01 Shape Divider Theme Inheritance
- 2026 07 02 Icon Block Dynamic Render Pilot
- 2026 07 06 Section Divider Block Design
- 2026 07 06 Section Style Variations Fse Design
- 2026 07 06 Section Styles Editor Preview
- 2026 07 07 Row Grid Overlay Hover Parity Design
- 2026 07 21 Conditional And Dup Label Sourcing
- 2026 07 23 Theme Block Type Animation Defaults
- 2026 08 16 Chart Block
- 2026 08 16 Greenshift Gap Roadmap
- 2026 08 17 Woocommerce Surface
- 2026 08 24 Loop Carousel
- 2026 08 24 Star Rating Block
- 2026 09 17 Abilities Drift Prevention
- 2026 09 17 Abilities Drift Prevention Implementation
- 2026 09 29 Existing User Regression Fixes
- 2026 09 29 Release Preflight Fixes
- Readme
- 2026 07 02 Block Authorability Audit
- 2026 09 29 Regression Fixes
- 2026 09 29 Release 2.9.0
- 2026 09 29 Release Fixes
- 2026 10 19 Bug Hunt
- 2026 10 20 Bug Hunt Round 2