-
Notifications
You must be signed in to change notification settings - Fork 68
feat: add an option to change displayed taxonomy instead of category #3679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe changes introduce support for displaying custom taxonomies in the Posts block instead of hardcoded categories. A new Changes
Sequence DiagramsequenceDiagram
participant Editor as Editor (edit.js)
participant UI as TaxonomyControl
participant Attr as Block Attributes
participant Hook as usePostsQuery Hook
participant API as Backend (index.php)
participant Frontend as Frontend Render
Editor->>Attr: User selects taxonomy type
Attr->>UI: taxonomyTypeToDisplay updated
UI->>Attr: onChangeTaxonomyTypeToDisplay triggered
Attr->>Hook: taxonomyTypeToDisplay in attributes
Hook->>API: POST request with taxonomy_type_to_display
API->>API: get_taxonomy_term_list_by_id(post_id, taxonomy)
API->>Frontend: Return posts with selected taxonomy terms
Frontend->>Frontend: Render taxonomy terms instead of categories
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Pull request artifacts
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/taxonomy-control/index.js (1)
148-153: Add safe defaults for the new taxonomyTypeToDisplay props to avoid breaking deprecated code.The deprecated
v2/block/blog-postsblock does not pass the newtaxonomyTypeToDisplayandonChangeTaxonomyTypeToDisplayprops. When this block's Post Type changes (line 152), the undefined handler throws an error. Additionally, the new "Taxonomy to Display" control (lines 202, 205) calls undefined. Add these props todefaultPropsfor backward compatibility.Proposed fix (defaultProps)
TaxonomyControl.defaultProps = { postType: 'post', onChangePostType: () => {}, taxonomyType: 'category', onChangeTaxonomyType: () => {}, taxonomy: '', onChangeTaxonomy: () => {}, allowReset: false, + taxonomyTypeToDisplay: 'category', + onChangeTaxonomyTypeToDisplay: () => {}, }
fixes #3678
This is not a bug but a feature request. The selected taxonomy under
Filter by Taxonomyis used for filtering which post items are displayed. To be able to display custom taxonomy terms instead ofCategories, we have to add that option.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.