?
Solved

Wordpress Admin Menu Placement

Posted on 2011-04-29
12
Medium Priority
?
788 Views
Last Modified: 2012-05-11
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
Comment
Question by:drumichael87
12 Comments
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35494972
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
 
LVL 1

Author Comment

by:drumichael87
ID: 35495049
Sorry- I am talking about an admin page in the Wordpress BACKEND. IE: plugin options page.
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35495541
You mean you don't want to have to drag it, but to have it added to the top on insertions?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35495545
You don know you can click and drag it into place right?
0
 
LVL 1

Author Comment

by:drumichael87
ID: 35497130
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
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35497951
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
 
LVL 1

Author Comment

by:drumichael87
ID: 35498059
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
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35498656

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
 
LVL 1

Author Comment

by:drumichael87
ID: 35499305
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
 
LVL 3

Accepted Solution

by:
mjjdesigns earned 2000 total points
ID: 35507786
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
 
LVL 31

Expert Comment

by:gwkg
ID: 35509778
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
 
LVL 1

Author Closing Comment

by:drumichael87
ID: 35509942
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Now that you've installed WordPress 2.9 (http://www.experts-exchange.com/articles/Web_Development/Blogs/WordPress/WordPress-2-9-What-to-Expect-When-Upgrading-to-WordPress-2-9.html?) on your site, you need to install some plugins to get the most out …
While Plesk offers many potential benefits to website administrators, including compatibility with Windows Server and other leading technologies, the company has also been working to differentiate it from other control panels for content management…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question