Opened 8 years ago
Closed 8 years ago
#41161 closed enhancement (wontfix)
More Flexibility With Navigation Menu Item Types
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.8 |
Component: | Menus | Keywords: | |
Focuses: | administration, template | Cc: |
Description
Currently, WordPress only supports 4 types of navigation menu items.
post_type
post_type_archive
taxonomy
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:
<?php 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...
Thanks!
Change History (3)
#3
@
8 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
@michael.ecklund thanks for reporting!
The filter wp_setup_nav_menu_item
is available and allows filtering of the $menu_item
and will give you the access the items you're looking to modify.
Codex reference - https://codex.wordpress.org/Function_Reference/wp_update_nav_menu_item
Duplicated: https://core.trac.wordpress.org/ticket/41162