WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 7 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' );
share|improve this answer
thanks, but doesn't seem to to work – Keith Dec 19 '12 at 20:33
where are you putting the code? – Steve Claridge Dec 19 '12 at 20:41
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
Thank you, it is working. – Keith Dec 20 '12 at 11:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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