DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Introduced in WordPress 3.1, the Admin bar is a new feature that many users like. Today, I’m going to show how you can add custom links to WordPress admin bar.

To add a custom link to WordPress admin bar, simply paste the following code into your functions.php file. Modify the code as needed to fit your needs.

function mytheme_admin_bar_render() {
	global $wp_admin_bar;
	$wp_admin_bar->add_menu( array(
		'parent' => 'new-content', // use 'false' for a root menu, or pass the ID of the parent menu
		'id' => 'new_media', // link ID, defaults to a sanitized title value
		'title' => __('Media'), // link title
		'href' => admin_url( 'media-new.php'), // name of file
		'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
	));
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );

Thanks to Jeff Starr for the cool tip!

Tags

2 Comments

  1. I have found a simple plugin for adding custom links to WordPress admin bar.

    check this out: http://wordpress.org/extend/plugins/custom-adminbar-menus/

  2. Thanks to author and Jose for plugin name!

Leave a Comment

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