Search
Close this search box.

How to Add and Remove WP Admin Bar Links

WordPress 3.1 introduced a new feature, the WP Admin Bar.

Here’s how to customise it by removing existing links and adding new links.

The WP Admin Bar

The new Admin Bar appeared in the v3.1 release of WordPress many developers were quick to disable it completely.

True, it could have been turned off by default allowing the feature to be discovered.  This may have stopped the “Woah – what is that thing at the top of my website and how can I get rid of it?” attitude.

It’s only now that developers are starting to play with the features it offers, customising it to their website needs.

Our WP Admin Bar with a “Customer Home” link for our clients

Customizing The WP Admin Bar

Modifying the WP Admin Bar works by adding a function and hook to your theme’s functions.php file.  Here’e the basic code.

[pastacode lang=”php” manual=”%2F%2F%20Admin%20Bar%20Customisation%0Afunction%20mytheme_admin_bar_render()%20%7B%0Aglobal%20%24wp_admin_bar%3B%0A%0A%2F%2F%20Remove%20an%20existing%20link%20using%20its%20%24id%0A%2F%2F%20Here%20we%20remove%20the%20’Updates’%20drop-down%20link%0A%24wp_admin_bar-%3Eremove_menu(‘updates’)%3B%0A%0A%2F%2F%20Add%20a%20new%20top%20level%20menu%20link%0A%2F%2F%20Here%20we%20add%20a%20customer%20support%20URL%20link%0A%24customerSupportURL%20%3D%20’http%3A%2F%2Fwww.gravitationalfx.com%2F’%3B%0A%24wp_admin_bar-%3Eadd_menu(%20array(%0A’parent’%20%3D%3E%20false%2C%0A’id’%20%3D%3E%20’customer_support’%2C%0A’title’%20%3D%3E%20__(‘Customer%20Support’)%2C%0A’href’%20%3D%3E%20%24customerSupportURL%0A))%3B%0A%0A%2F%2F%20Add%20a%20new%20sub-menu%20to%20the%20link%20above%0A%2F%2F%20Here%20we%20add%20a%20link%20to%20our%20contact%20us%20web%20page%0A%24contactUsURL%20%3D%20’http%3A%2F%2Fwww.gravitationalfx.com%2Fcontact%2F’%3B%0A%24wp_admin_bar-%3Eadd_menu(array(%0A’parent’%20%3D%3E%20’customer_support’%2C%0A’id’%20%3D%3E%20’contact_us’%2C%0A’title’%20%3D%3E%20__(‘Contact%20Us’)%2C%0A’href’%20%3D%3E%20%24contactUsURL%0A))%3B%0A%7D%0A%0A%2F%2F%20Finally%20we%20add%20our%20hook%20function%0Aadd_action(%20’wp_before_admin_bar_render’%2C%20’mytheme_admin_bar_render’%20)%3B” message=”” highlight=”” provider=”manual”/]

WP Admin Bar Default Link IDs

The WP Admin Bar default link IDs can be found in the /wp-includes/admin-bar.php file.  Here’s a summary of those link IDs:

  • my-account – the link to your account (if you haven’t enabled avatars)
  • my-account-with-avatar – the link to your account (if avatars are enabled)
  • my-blogs – the ‘My Sites’ menu if the user has more than one site
  • get-shortlink – provides a Shortlink to that page
  • edit – link to Edit [content-type]
  • new-content – the ‘Add New’ drop-down menu link
  • comments – the ‘Comments’ drop-down menu link
  • appearance – the ‘Appearance’ drop-down menu link
  • updates – the ‘Updates’ drop-down menu link

Using the WP Admin Bar

We have recently introduced a client area where our customers can log in and get their own relevant project information.

Each customer has a “home page” which is specified on the users profile and we have added a “Customer Home” link to the WP Admin Bar that always takes them to their specific homepage, wherever they may be in our site.

How have you customised yours?

Take a screenshot of your WP Admin Bar customizations and send them in to us.  We’ll publish the best ones along with a link to the website on our Facebook Page.

Was this article helpful?
YesNo