Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#41162 closed enhancement (duplicate)

More Flexibility With Navigation Menu Item Types

Reported by: michaelecklund's profile michael.ecklund Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: Menus Keywords:
Focuses: administration, template Cc:


Currently, WordPress only supports 4 types of navigation menu items.

  1. post_type
  2. post_type_archive
  3. taxonomy
  4. custom

Which is fine if that's how it needs to be for now. However, since anyone who decides to create their own menu type, their links will ALWAYS default to "Custom Link". At a minimum can we at least get a filter to override the menu type label?

I've created my own section with a custom menu type. Now all of my links show up as "Custom Link". Which is confusing, because there's actually a section to add "Custom Links". My links are not "Custom Links". I'd like to be able to filter that label text (at a minimum).

Referring to ./wp-includes/nav-menus.php Line 769; As of WordPress 4.8. Code block:

else {
    $menu_item->type_label = __('Custom Link');
    $menu_item->title = $menu_item->post_title;
    $menu_item->url = ! isset( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url;

Could just add a filter...

$menu_item->type_label = apply_filters( 'some-hook-name', __('Custom Link') );

I mean, if you're going to just default everything to custom, at least provide some flexibility here...


Change History (3)

#2 @michael.ecklund
6 years ago

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

Duplicate of #41161.

#3 @netweb
6 years ago

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