I wish to remove the sub menus of post/link/media under the add new menu in the admin bar. I can remove the entire menu but I actually only want to remove the sub menu's

$wp_admin_bar->remove_menu('my-account-with-avatar');
up vote 12 down vote accepted

See the Admin Bar remove_node function:

add_action( 'admin_bar_menu', 'remove_wp_nodes', 999 );

function remove_wp_nodes() 
{
    global $wp_admin_bar;   
    $wp_admin_bar->remove_node( 'new-post' );
    $wp_admin_bar->remove_node( 'new-link' );
    $wp_admin_bar->remove_node( 'new-media' );
}
  • I have the code in my plugin, I have also tried calling - global $wp_admin_bar; insidne the function – Keith Dec 19 '12 at 20:44
  • @Keith, code tested and working now. – brasofilo Dec 20 '12 at 4:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.