The WP-Admin bar was added in version 3.1 of WordPress and it’s made the lives of many WordPress publishers a lot easier. The bar appears to logged in users with sufficient privileges on the front-end and dashboard of a WordPress blog. It offers easy navigation to different administrative tasks based on the type of page being viewed.

You can use this wonderful time saving tool to your advantage by adding custom links to the bar. This could be utilized by a theme or plugin to provide better access to a specialized functionality. The code below simply adds a constant link to the bar, but you could customize it further by adding different links when different conditionals to the add_action call.


function yourslug_admin_bar_link() {
	global $wp_admin_bar;
	$new_menu = array( // change this array to your link info
		'parent' => 'new-content', // parent menu ID (0=root menu)
		'id' => 'link_ID',
		'title' => __('Link Title'),
		'href' => 'relative/file.php',
		'meta' => array( // false for none
			'html' => '',
			'class' => '',
			'onclick' => '',
			'target' => '',
			'title' => '' ) ); 
	$wp_admin_bar->add_menu( $new_menu );
add_action( 'wp_before_admin_bar_render', 'yourslug_admin_bar_link' );


Remember to change yourslug_ to something unique if you are going to be using this function in the public namespace.

One Thought on “Add a Link to the WP-Admin Bar

  1. shervin on January 19, 2013 at 10:08 pm said:


Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation