Opened 3 years ago
Closed 2 years ago
#14832 closed enhancement (fixed)
Allow separate label for menu text when registering post type
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | Post Types | Version: | 3.0.1 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: |
Description
When registering a post type the labels array allows you to provide various titles to display.
If you register a new post type with a long-ish label, you may want to provide a shorter label for display in the admin menu so that it doesn't wrap onto 2 lines. The current labels array does not provide an option to do this.
Attachments (1)
Change History (16)
- Milestone changed from Awaiting Review to 3.1
- Owner set to nacin
- Status changed from new to accepted
I think we had discussed about something like that —name_short or label_short or something to that effect— in the 3.0 dev cycle, but it seems the idea somehow slipped among all the details of the implementation.
comment:5
leewillis77 — 3 years ago
+1 from me - this would be very useful for a project I'm working on.
- Keywords register_post_type removed
I'm not sure if this is how I want to do it. Feels like maybe we need a system to handle context and such, otherwise the labels array is going to keep growing as more requests and labels come in.
Do you think 'short_label' would be better than 'menu_label' as per the comment above by demetris? That way it would make more sense if used in other scenarios.
Or perhaps filter labels based on context so you could change the label when used in the menu context - is that sort of what you're suggesting nacin?
- Resolution set to fixed
- Status changed from accepted to closed
comment:10
scribu — 3 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
register_taxonomy('publisher', 'book', array('label' => 'Publisher'));
The Menu label remains "Post Tags".
comment:11
scribu — 3 years ago
- Keywords needs-patch added; has-patch removed
comment:12
nacin — 3 years ago
Would be easier to patch this into get_post_type_labels, but it'd be better in _get_custom_object_labels.
comment:13
nacin — 3 years ago
- Resolution set to fixed
- Status changed from reopened to closed
comment:14
nacin — 2 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
menu_name doesn't work with show_in_menu = 'submenu'. Fixing.
comment:15
nacin — 2 years ago
- Resolution set to fixed
- Status changed from reopened to closed

The attached patch adds a 'menu_label' to the labels array that can be used to provide a separate label for the admin menu. If you do not provide a menu_label, then it should default to just using the standard default label.