Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I add a Title to my Admin Menu on the left side of the dashboard? Not a link, but just a title? I want do this in my functions and not use a plugin. Also which template file handles this menu?

I found this but I have no idea of how to use it:

Adding a Word at the Beginning of the Menu This example will allow you to add the word of your choice to the beginning of your menu as a list item. In this example, the word "Menu:" is added at the beginning. You may want to set an id on the list item ("item-id" in this example) so that you can use CSS to style it.

<?php wp_nav_menu( array( 'theme_location' => 'primary', 'items_wrap' => '<ul><li     
id="item-id">Menu: </li>%3$s</ul>' ) ); ?>
share|improve this question
    
There isn't a template, they're generated by add_menu_page and add_object_page, among others. codex.wordpress.org/Function_Reference/add_menu_page –  Andrew Bartel May 16 '13 at 20:33
    
Please help me man this is getting to me –  Jusherb May 16 '13 at 20:49
    
wp_nav_menu is for displaying a menu that is created under appearance > menus, what specifically do you want to add and where? –  Andrew Bartel May 16 '13 at 20:50
    
OOOOOOKKKKK sir Thank You for the help but MAYBE I SHOULD RESTATE:>>>> I NEED TO ADD A >>>>>>TTTITTTTLE<<<<< TITLE, TITLE, WITHOUT A >>>>LINK<<<< I NEED A TITLE TO THE MENU NOT ANOTHER LINK, A TTTTTTIIIILE AT THE TOP OF THE ADMIN MENU WHICH IS LOCATED ON THE LEFTSIDE OF THE DASHBOARD THAT IS NOT CLICKABLE... –  Jusherb May 16 '13 at 20:53
    
Man, Dont take offense to me I'm just frustrated from hours and hours of research... –  Jusherb May 16 '13 at 20:57
show 6 more comments

1 Answer 1

Menu items are added to the left hand dashboard menu with a few different functions, depending on where you want it to display. You will probably want to use add_menu_page. The last parameter of this function will determine how far up/down it displays. These are the defaults that you can position your item around:

Positions for Core Menu Items

2 Dashboard 4 Separator 5 Posts 10 Media 15 Links 20 Pages 25 Comments 59 Separator 60 Appearance 65 Plugins 70 Users 75 Tools 80 Settings 99 Separator

In your active theme's functions.php file, you'll want to add the menu item and include a javascript file.

add_action('admin_menu','my_non_clickable_menu_item');
function my_non_clickable_menu_item() {
    add_menu_page( 'Title', 'Title', 'update_plugins', 'whatever/whatever', '', '', 50 );
}

add_action('admin_enqueue_scripts','enqueue_my_menu_js');
function enqueue_my_menu_js() {
    wp_enqueue_script('my_menu.js',/path/to/my_menu.js');
}

This will create a menu item called Title that goes to the non-existent whatever/whatever page. We're going to use string to target it later, and you can change it to whatever you want. To view this menu item, a user must have the 'update_plugins' ability, which by default is restricted to administrators. The two blank parameters are a custom icon and a function that displays the content of the link, we don't need those. The 50 is the position. It will create it like so: enter image description here

In your javascript file:

jQuery(document).ready(function($) {
    $('a').click(function(e) {
        if($(this).attr('href') == 'whatever/whatever') {
            e.preventDefault();
        }
    });

    $('ul#adminmenu').find('a').each(function(e) {
        if($(this).attr('href') == 'whatever/whatever') {
            $(this).css('color','#000').css('cursor','default');
        }
    });
});

This will turn "Title" black (the #000), make the cursor not change to a pointer on hover and have it not do anything when it's clicked. This will slow your admin section down just a bit, but it shouldn't be much of a problem. You can style it further through the jquery css() function, like adding a border, or you could remove the icon to it's left. Find out how to target it using a program like firebug or other developer tools in browsers.

share|improve this answer
    
Man that's complicated as He(Double L Hockey sticks), theres no core file that I can just go in and add a li to? –  Jusherb May 16 '13 at 21:59
    
Nope, the menu is built dynamically. –  Andrew Bartel May 16 '13 at 22:04
    
Ohhhh got you! Dang that caught me by surprise... Well question: There is no way to get to #adminmenu ul? –  Jusherb May 16 '13 at 22:06
    
You could append a list item to it with jquery api.jquery.com/append –  Andrew Bartel May 16 '13 at 22:12
    
If I was to go the JQuery way where would I need to enter the coding. How would I go about using that technique. and again I do not mind editing core files so if there is an easier to all of this by editing a core file I do not care –  Jusherb May 16 '13 at 23:27
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.