Feat: Navigation Link – Add "Show child categories" toggle for taxonomy Category Links#77679
Conversation
…he child categories for a navigation-link block
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @priyanshuhaldar007. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @priyanshuhaldar007! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
What?
Closes https://core.trac.wordpress.org/ticket/64988
Adds a
showChildCategoriesboolean attribute to thecore/navigation-linkblock. When enabled on a Category Link block, child categories of the selected parent are automatically fetched and rendered as a nested submenu/dropdown in the frontend navigation.Why?
The Navigation block's Category Link currently only links to a single category archive — it has no way to expose child categories as a submenu. This is inconsistent with the Page List block, which supports hierarchical parent–child page structures out of the box. Users with hierarchical taxonomies (blogs, WooCommerce stores, taxonomy-heavy sites) are forced to manually construct submenus or write custom code to replicate behavior that Page List provides natively.
How?
showChildCategories: { type: boolean, default: false }toblock.jsonforcore/navigation-link.ToggleControlinedit.js(block sidebar inspector) that toggles the new attribute. The control is only shown when the selected linkkindistaxonomy.render_block_core_navigation_link) to callget_terms()withparentset to$attributes['id']whenshowChildCategoriesistrueandkindistaxonomy.<li>navigation items inside awp-block-navigation__submenu-container, reusing the same Interactivity API markup pattern (data-wp-*attributes, submenu toggle button) as existing inner-block-based submenus.has-child/wp-block-navigation-submenuclasses and submenu icon button are applied when either inner blocks or dynamic child terms are present, ensuring consistent hover/click/focus behaviour.Testing Instructions
Testing Instructions for Keyboard
EnterorSpaceto open the submenu.Escapeto close the submenu and confirm focus returns to the parent item.Implementation Screencast
Screen.Recording.2026-04-26.at.12.20.42.PM.mov
Use of AI Tools
Claude (Anthropic) was used to assist with drafting this PR description, and Gemini was used to assist with debugging.