Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');
share|improve this question
add comment

1 Answer

up vote 3 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
add comment

Your Answer

 
discard

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.