Add sorting by name or count in categories block#66453
Add sorting by name or count in categories block#66453SantosGuillamot wants to merge 6 commits intotrunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| }, | ||
| "order": { | ||
| "type": "string", | ||
| "default": "asc" | ||
| }, | ||
| "orderBy": { | ||
| "type": "string", | ||
| "default": "name" |
There was a problem hiding this comment.
I kept the default query to prevent unexpected results.
There was a problem hiding this comment.
I was also wondering if we should create a query attribute like the query loop has and include properties there like taxonomy. But I am not sure how it would work with backward compatibility.
| { | ||
| /* translators: label for ordering taxonomies by number of posts in descending order */ | ||
| label: __( 'Highest #' ), | ||
| value: 'count/desc', | ||
| }, | ||
| { | ||
| /* translators: label for ordering taxonomies by number of posts in ascending order */ | ||
| label: __( 'Lowest #' ), | ||
| value: 'count/asc', | ||
| }, |
There was a problem hiding this comment.
I wasn't sure how to label these options.
|
Size Change: +261 B (+0.01%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in bcc3a09. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11589735416
|
What?
Add a new setting to the Categories block to be able to order the list of taxonomies based on the name or the posts count. It is similar to what the query loop is doing.
Why?
They are supported queries and it provides more flexibility to the user.
How?
Include
orderandorderByin the block attributes and use their value in the query to retrieve the categories.Additionally, I added a Select control with the different options.
Testing Instructions