With WordPress 3.1 came a whole slew of new features. Perhaps the most visually obvious one is the admin bar, which will be a familiar site to any users of wordpress.com.
It provides quick access to all the main areas of your site that you use most often, like creating a new post or page, moderating comments or modifying widgets. It’s probably a good start for the places on your own site that you visit the most, but I’m betting there are other pages that you visit frequently that didn’t find their way on to the admin bar.
So here’s how to customise the admin bar to add or remove links as needed. All of these modifications will require modifying your functions.php file. If you’re not sure how to do this, see How To Edit your Theme Files.
Add links to the menu bar
If you want to add links to the menu bar, add this snippet to your functions.php file. The code has a few variables which are explained below:
The variables that you’ll interested in are id, parent, title and href. id is merely a unique identifier for the link and parent dictates which menu the link will appear in. In this example, it is shown under the my-blogs menu. The following list shows you all the different menus that WordPress supports natively, but if you want a different menu altogether, you can add a custom one:
- my-account-with-avatar or my-account – Your account information (appears as your name)
- my-blogs – All the sites that you are a member of (appears as My Sites)
- edit – For editing posts or pages (appears as Edit Post or Edit Page)
- new-content – For adding new posts or pages (appears as Add New)
- comments – Comment moderation area (appears as Comments)
- appearance – Modifying widgets, menus etc. (appears as Appearance)
- updates – For updating plugins and themes etc. (appears as Updates)
- get-shortlink – Provides shortlink for current page (appears as Get Shortlink)
The title variable will be what is shown in the menu for the item and the href variable is the URL for the link. So in the example above, I’ve created a link called Do It With WordPress under the My Sites menu which links to the admin area of my WordPress site.
Remove menus altogether
To completely remove a menu from the admin bar, you can use the function below, replacing the menu names with the ones that you want to remove. You can remove more or less than the 2 that I have shown by adding or removing lines:
Create a custom menu
If you’d rather keep all your links under a completely new menu, you can create one by using the following function:
In this example, I created a new menu called Social Networks, with two links under it, one to my Facebook page and one to my Twitter page. Pretty swish huh? You can also set what position it will take in the admin bar, by setting an order value. Just change the last line to the following, where 1000 is the order value:
Creative menu ideas
As I got to thinking about it, you could really put some cool things together using this functionality. For example, you could create a menu of URLs that will submit your post to social networking sites like Facebook and Twitter, or you could create a set of links for shortening your URL with different services like is.gd and bit.ly. I also saw a really creative idea of incorporating a form for searching a site in to the admin bar. The possibilities are endless, so what are you going to do with it? I’d love to see what you come up with.
Remove the bar altogether
Perhaps you’ve decided that the WordPress Admin Bar isn’t for you. All you need to do to hide the WordPress Admin Bar is go to your profile (Users > Your Profile from the dashboard) and uncheck the two boxes which determine when the admin bar should be displayed and it’ll never bother you again. That was painless wasn’t it…
If you want to go a step further and disable the WordPress Admin Bar for all users on the site, you can add the following function to your functions.php file: