Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#60631 closed defect (bug) (invalid)

block_core_navigation_render_inner_blocks block taxonomy type is 'tag', should be 'post_tag'

Reported by: anaid's profile anaid Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords: dev-feedback close
Focuses: Cc:

Description

In the block_core_navigation_render_inner_blocks filter, when iterating over the menu items, the type attribute for a Post Tag has value 'tag'. However, to retrieve information about this taxonomy, the get_taxonomy method requires value 'post_tag'. Seems like a rename was performed somewhere while implementing the block editor.

	function block_core_navigation_render_inner_blocks($items)
	{
		foreach ($items as $key => $item)
		{
			$type = $item["attr"]["type"];			
			$taxonomy = get_taxonomy($type === "tag" ? "post_tag" : $type); // Required workaround because of discrepancy
			// <snip>
		}
		
		return $items;
	}

Change History (4)

#1 @swissspidy
12 months ago

  • Component changed from Taxonomy to Editor
  • Focuses multisite removed
  • Keywords dev-feedback close added

From what I can see, the type attribute for the core/navigation-link block does not map 1:1 to a taxonomy type. Type refers to the type of link. It could be "page", "post", "category", "tag", or something custom.

In this regard the code you shared is flawed as $item["attr"]["type"] does not actually mean it's about a taxonomy.

block_core_navigation_link_build_variations and build_variation_for_navigation_link then create block variations for every registered post type and taxonomy. There, there is a mapping to post_tag as expected.

See https://github.com/WordPress/gutenberg/blob/705d77cd19b36ec36a04b7918aeab7282747d4a7/packages/block-library/src/navigation-link/index.php#L269-L326

So from what I can see it works as expected.

Please note that tickets related to the Gutenberg Editor should be filed on the Gutenberg GitHub Repository in general. So if you still think there is something that needs to be changed, please open an issue there for discussion.

#2 @anaid
12 months ago

Thanks for your message.

The use case is for taxonomies only. How to I get the corresponding taxonomy for a navigation-link block?

The functions you mention map from post_tag to tag but I need the reverse..

Version 0, edited 12 months ago by anaid (next)

#3 @anaid
12 months ago

  • Resolution set to invalid
  • Status changed from new to closed

Ah, never mind, I get it. I'll build a reverse lookup myself using the methods you supplied.

Thank you

#4 @swissspidy
12 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.