How to break line / add <br> to ADMIN menu
Disclaimer: This question is not about frontend nav menu
I am looking for a way how to break line in a menu item label in WP admin sidebar menu, sidereason is that the custom post type label I am registering is too long for 1 line and I don't really want to mess with the width of the admin menu.
I tried adding both \n
and br
into the custom post type label, but br
gets escaped and line breaks are not converted.
I tried to look on the Internet, but I mainly found articles how to line break in frontend menu items which is not what I am looking for.
Is there some sort of filter or other way to do this?
Note: I would also like to avoid tinkering with anything global
or special characters like nonbreaking hyphen, if possible
Note2: I know there is auto linebreak in place, however I need a manually added line break because the term is in some-thing
format so it breaks on dash which is unwanted behavior
EDIT
Turns out, my problem is specific to the register_post_type
label, adding menu item manually with add_menu_page()
does not seem to have this problem, so I am sharing my code for registering the post type:
Please note that, this does reproduce the issue and I also did try putting label
arg there and removing labels['name']
(since it overrides label
) and it produced the same issue.
register_post_type(whatever_some, [
'labels' = [
'name' = 'Whatever a-something',
'singular_name' = 'Whatever a-something',
'add_new' = 'a-something - new',
'add_new_item' = 'a-something - new',
'edit_item' = 'Edit whatever a-something',
'all_items' = 'All whatever a-something',
],
'public' = true,
'menu_icon' = 'dashicons-admin-settings',
'capability_type' = 'page',
'hierarchical' = false,
'supports' = ['title', 'editor', 'thumbnail', 'excerpt', 'author'],
'has_archive' = true,
'rewrite' = ['slug' = 'whatever-asomething'],
]);
Topic line-breaks admin-menu admin wp-admin Wordpress
Category Web