-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Summary:
The Gutenberg Query Loop block currently lacks native support for sorting and filtering posts by custom meta fields such as event dates, a critical feature for event-centric Custom Post Types (CPTs). This limits editor flexibility when creating event listing pages or date-sensitive content using the block editor and full site editing (FSE).
Problem Statement:
Event management websites and other advanced use cases require displaying posts sorted by custom event dates and filtering for upcoming or past events. The native Query Loop block only supports basic sorting by publish date or title and does not expose UI controls for meta field sorting or date range filters.
This gap forces developers to rely on custom PHP snippets, plugins, or shortcode workarounds, complicating block editor workflows and reducing the benefit of native block-based site design.
Proposed Enhancements:
Sorting by Custom Meta Fields:
Add intuitive UI controls in the Query Loop block inspector sidebar to select a custom meta key and sort order (ascending/descending). Support numeric, string, and date meta types.
Date Range Filters:
Provide preset filters such as “Show Upcoming Events,” “Show Past Events,” and allow users to specify custom date ranges. These filters should integrate seamlessly with meta key sorting.
REST API Support:
Extend REST API query parameters to accept these meta queries and ensure block editor previews reflect the filtered/sorted data accurately on both backend and frontend.
Extensibility Hooks:
Create actions and filters allowing plugin developers to extend the Query Loop block with new sorting and filtering options, including specialized controls for event CPTs.
Benefits:
Empowers content editors and site builders to create event pages and other custom sorted lists visually, without PHP.
Improves full site editing experience with live previews matching front-end queries more precisely.
Reduces development overhead by removing the need for custom block wrappers or plugins for event sorting.
Enables consistent, accessible UX for event display across themes and sites using native WordPress blocks.
Context / References:
Plugins like The Events Calendar support event CPTs with event dates but require non-block workarounds for query filtering and sorting.
Community projects such as Query Loop Future Filter demonstrate demand for date range filters in Query Loop blocks.
Example Use Case:
A site builder wants to create an “Upcoming Events” page showing custom CPT posts sorted ascending by event date and filtered to exclude past dates. They configure this in the Query Loop block sidebar by choosing the “event_date” meta key, sorting ascending, and applying the “upcoming events” date filter—all visually, with no code.
I have struggled a lot and spent most of the day today. With AI creating a CPT for events. Creating a meta box for event date in the sidebar of an events post. Working on using the Query Loop block and custom code to show events on the frontend based on the events date meta field. But after a lot of struggles I have given up for now I will likely need to add an event plugin. I really just want a CTP and use the Query Loop block to show the upcoming events