How to hide “post” link from the admin bar

After studying several blogs, I figured out that to add/edit/delete admin bar items need to do something like this:

add_action( 'wp_before_admin_bar_render', 'wpse20131211_admin_bar' );

function wpse20131211_admin_bar() {
   global $wp_admin_bar;
   $wp_admin_bar->remove_menu('wp-logo');
   $wp_admin_bar->remove_menu('comments');
}

But with this I can remove comments links, wp logo etc. But can’t remove the Post link under the + New menu on the admin bar.
post link under admin bar

I tried with:

$wp_admin_bar->remove_menu('post');

and similarly with 'posts', 'add-post' etc. But failed.

2 Answers
2

Try this:

$wp_admin_bar->remove_node( 'new-post' );

It will remove Post link under the admin bar’s + New link.

LEARN MORE: remove_node() – WordPress Codex

Leave a Comment