Contributors: carstenbach
Tags: query, block, taxonomy, groupby, posts, extension
Tested up to: 6.8
Stable tag: 0.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Extends the core Query Loop block with a "Group by Taxonomy" option, enabling grouped front-end output by any selected taxonomy.
This plugin adds a Group by Taxonomy Inspector panel to the core Query Loop block. When a taxonomy is selected, the query results are modified server-side via posts_clauses to join taxonomy tables and order by term name — enabling grouped output on the front end.
Motivation:
We needed a way to query upcoming events, unique by theater-productions. Try this plugin together with GatherPress to see, what we wanted to achieve.
Features:
- Adds a "Group by Taxonomy" panel to the core Query Loop block Inspector.
- Supports any public taxonomy associated with the selected post type.
- Uses
pre_render_blockandquery_loop_block_query_varsto inject custom query variables. - Modifies the SQL via
posts_clausesfor efficient taxonomy-based ordering and grouping. - No additional blocks required — works directly with the existing
core/queryblock and its variations. - Fully compliant with WordPress and WordPress VIP coding standards.
- Upload the plugin files to the
/wp-content/plugins/query-groupedby-taxonomydirectory. - Activate the plugin through the 'Plugins' screen in WordPress.
- In the block editor, insert a Query Loop block and open the "Group by Taxonomy" panel in the Inspector sidebar.
- Select a taxonomy to enable grouping on the front end.
The SQL query is modified to join taxonomy tables and order by term name. The actual rendering depends on the Query Loop's inner blocks and any additional front-end processing.
Yes. Any publicly registered taxonomy associated with the selected post type will appear in the taxonomy selector.
All notable changes to this project will be documented in the CHANGELOG.md.
