• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 801
  • Last Modified:

Wordpress Admin Menu Placement

When adding a top-level admin menu to wordpress backend, the menu item is put all the way at the bottom of the list.  

Anyone have any idea how to get it moved up closer to the top?

Thanks!!
0
drumichael87
Asked:
drumichael87
1 Solution
 
jeremyjared74Commented:
If you are using the WordPress Nav Menu that was released with 3.0, you can drag and drop where you want it:

Here is a quick informative article from Justin Tadlock:
http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus

If you don't have this function, or don't want to use it, you can order them by assigning the page or post a number in the post/page editor screen. You will see it on the right. If it is a sub-page select the parent from the dorp-down menu. To order them, you add a number to the field that says 0 by default. Start at 0 for top level and number them in ascending order to place them how you want.
0
 
drumichael87Author Commented:
Sorry- I am talking about an admin page in the Wordpress BACKEND. IE: plugin options page.
0
 
jeremyjared74Commented:
You mean you don't want to have to drag it, but to have it added to the top on insertions?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
jeremyjared74Commented:
You don know you can click and drag it into place right?
0
 
drumichael87Author Commented:
I have attached a picture to help you understand.  You see at the bottom - the "Assignments" Menu?  That is my plugin.  I want the "Assignments" button to be up at the top like the "Tickets" button.  

Does this help explain my question?
menu.PNG
0
 
jeremyjared74Commented:
OK I see what you mean now. There are a few options to change this. I am going to give you the easy version first.

1. The Easy Way- Add it to the top-center of the Admin Page

To do this, you need to find the URL of the button. You can right click on the "Assignments" button shown and choose copy link location. Then paste it into a blank text file.

Here is an example I used to change a menu item on my Admin screen:
body.wp-admin div#wpwrap div#wpcontent div#wpbody ul#adminmenu li#toplevel_page_edit-post_type-shortcodepro.wp-has-submenu {
position: absolute !important;
top: 0 !important;
left:500px; !important;
clear: both !important;
}

Open in new window

NOTE:
The code above is only one of a few possible selectors. I also moved the one that was above it to make sure they use the same selectors, but with a different title. I noticed that one is a  li#toplevel_page_edit-post_type, while the other was li#toplevel_page_the-spcific-itme-tilte-here.

For the second instance I used this code to change it:
body.wp-admin div#wpwrap div#wpcontent div#wpbody ul#adminmenu li#toplevel_page_w3tc_general.wp-has-submenu {
position: absolute !important;
top: 0 !important;
left:700px !important;
}

Open in new window


You can view the link source to see which selector you need to use.

Once you have the found the correct way to identify the menu-item, you will need to edit the WordPress core file: colors-classic.css. You will find this file in the following path:
/wp-admin/css/colors-classic.css.

When you find the file noted above, open it with a text-editor and add the css code to the very bottom of the code inside. This will make it easier to undo if you don't like it.

NOTE:
When editing WordPress core files you should know that the changes will be lost in an upgrade to WordPress. You should save the edited part so you can transfer it over after the upgrade.

I will show you an alternative way if you don't want to do it this way.


Here is a screenshot of what the css changes look like on the page:
 Screenshot
0
 
drumichael87Author Commented:
that's not where I want the buttons to be - I want them to still be in the main list on the left, but i want it in the position that you see the "tickets" item in the image i uploaded.

Also, this is being developed as a plugin to be distributed to the public, so editing the wordpress core is out of the question.

What is your alternative method?
0
 
jeremyjared74Commented:

Sorry it took so long. You can add your plug-in to the Dashboard menu by saving this code as menu-test.php:


<?php
/*
Plugin Name: Menu Test
Plugin URI: http://codex.wordpress.org/Adding_Administration_Menus
Description: Menu Test
Author: Codex authors
Author URI: http://example.com
*/
/* Add Multiple Links to the Dashboard Menu */
 function FirstLink(){
  if(!current_user_can('manage_options')){
    wp_die( __('You do not have sufficient permissions to access this page.'));
  }
	echo "Hello World, I'm a great Dashboard Widget";
} 
 
 function SecondLink(){
  if(!current_user_can('manage_options')){
    wp_die( __('You do not have sufficient permissions to access this page.'));
  }
	echo "Hello World, I'm a great Dashboard Widget";
} 
function dashboardMenu(){ /* Dashboard Menu Link */
  if(function_exists('add_submenu_page'))
    add_submenu_page('index.php', __('First Link Name'), __('First Link Name'), 'manage_options', 'FirstLink', 'FirstLink');
    add_submenu_page('index.php', __('Second Link Name'), __('Second Link Name'), 'manage_options', 'SecondLink', 'SecondLink');
 }
  add_action('admin_menu', 'dashboardMenu');

?>

Open in new window


This was a mix or info I found at the WordPress Codex Page: http://codex.wordpress.org/Dashboard_Widgets_API

That didn't work, but when I combined it using this tutorial: http://technerdia.com/557_dashboard-link-in-wordpress.html  (I removed the iFrame part of this tutorial and combined it with the WP Codex suggestions).
If you want to add it as a plug-in, just create a folder and name it menu-test.php. Place the code above in a text editor and name it menu-test.php, then save it into the folder you just created. Next you need to zip the folder, go to the WP-Admin>Plug-ins>Add new, then choose upload and navigate to the zip folder you just created and click upload and activate it
.
You should be able to look at the plug-in code I'm sending and see how to implement into your theme. Let me know if you have any questions.

I've saved the code into a plug-in that you can upload to WordPress if you want to check it out:
menu-test.zip
0
 
drumichael87Author Commented:
I have the knowledge on how to add a submenu link.  Please read my question.  I want a top-level page added right where 'tickets' is showing on the image that I uploaded. (will upload again with this post for clarification.)

I have looked into the code of the 'tickets' plugin to try and figure out how they added the options page way up there, but I coudn't figure it out.  

Can anyone help? I upped the points to 500!!
menu.PNG
0
 
mjjdesignsCommented:
You're missing a position value on your menu item in your add_menu_page function.

add_menu_page('Test Toplevel', 'Test Toplevel', 'administrator', 'mt-top-level-handle', 'mt_toplevel_page','',10)

That 10 will put it at the bottom of the top most menu and should be exactly where you want it.
0
 
gwkgCommented:
To see the current menu positions use

print_r($GLOBALS['menu'])

Then you can follow mjj's code and put it exactly where you want it.

See here for more details

http://codex.wordpress.org/Administration_Menus#Top-Level_Menus
0
 
drumichael87Author Commented:
THANK YOU! I can't BELIEVE I didn't see that parameter in the codex!  I guess I did see it, but looked it right over.  

Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now