How can I remove the WP menu from the admin bar?

This menu is added in WP_Admin_Bar::add_menus() with an action: add_action( ‘admin_bar_menu’, ‘wp_admin_bar_wp_menu’, 10 ); To remove it take the same action – just one step later. The following code works as a mu plugin or as a regular plugin: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Remove WP Menu From Tool Bar … Read more

Edit specific nodes in WP_Admin_Bar

Yes I recently ran into the situation where I wanted to change the profile link in the user-info section of the admin bar. The problem is that you can only get all nodes, add and remove them. Not edit. And you also cannot modify the $wp_admin_bar->nodes property due it is private. When easily removing and … Read more

Hide admin bar on certain post type

Don’t hack your WordPress core. It’s overriden after every upgrade (plugins do exist for some reason). You can solve your problem in this way: 1) Open your single.php. 2) Define <?php function hideAdminBar ($post_id) { if (get_post_type ($post_id) == ‘post’) { add_filter (‘show_admin_bar’, ‘__return_false’); /* For removing the top blank space. */ echo ‘<style type=”text/css” … Read more

How to Remove All Admin Bar Menu Items?

I’m solving this getting all nodes from the Admin Bar, iterating through them and removing all that doesn’t have a parent. An exception is made to the User Actions menu (“Howdy, user_name”), which needs an extra checking. add_action( ‘admin_bar_menu’, ‘wpse_76491_admin_bar_menu’, 200 ); function wpse_76491_admin_bar_menu() { global $wp_admin_bar; if ( !is_object( $wp_admin_bar ) ) return; // … Read more

Remove WordPress Toolbar buttons

function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu(‘wp-logo’); } add_action( ‘wp_before_admin_bar_render’, ‘mytheme_admin_bar_render’ ); For specific user roles you can wrap the add_action in a conditional, something like if(current_user_can(‘editor’)){ add_action( ‘wp_before_admin_bar_render’, ‘mytheme_admin_bar_render’ ); } http://codex.wordpress.org/Roles_and_Capabilities

WordPress Admin Bar Moving Links

Unset Here’s an example of how to unset the comments link if the default status is ‘closed’ (offers 2 different approaches). /** * Disable ‘Comments’ link if default status is _closed_ */ function remove_comments() { $default_comment_status = get_option( ‘default_comment_status’ ); if ( $default_comment_status == ‘closed’ ) { remove_action( ‘admin_bar_menu’, ‘wp_admin_bar_comments_menu’, 50 ); // optional solution … Read more

Show admin bar only for some USERS roles

You can disable the admin bar via function: show_admin_bar(false); So with that in mind, we can hook into after_setup_theme and hide the admin bar for all users except administrator and contributor: function cc_wpse_278096_disable_admin_bar() { if (current_user_can(‘administrator’) || current_user_can(‘contributor’) ) { // user can view admin bar show_admin_bar(true); // this line isn’t essentially needed by default… … Read more

Modify Admin Bar Link

I’ve not worked with the admin-bar before. However, I found your question interesting and decided to take a look. If you add a function to handle the action hook ‘admin_bar_menu’ and set the priority to be higher than 70, you will have access to the raw admin_bar_menu nodes where you can modify the properties you … Read more

Add visit site to your toolbar instead of being in the dropdown

Not complicated, but a little tricky to get timing right. Something like this should work, but you might need to experiment with priority to get the link to specific position on the bar: add_action( ‘admin_bar_menu’, function ( $wp_admin_bar ) { if ( ! is_admin() ) { return; } /** @var WP_Admin_Bar $wp_admin_bar */ $wp_admin_bar->remove_node( ‘view-site’ … Read more