Add custom links to WordPress admin bar

Found this cool snippet wich allows you to add links to the WordPress admin bar.

Add the following code to your functions.php file and customize the parameters.

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' );
2 comments

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*