Removing Default Items from the WordPress Toolbar
Removing Default Items from the WordPress Toolbar
Add the following code to the functions.php file in your child theme’s folder to remove all the default items (or ‘nodes’) listed below:
-
function my_edit_toolbar($wp_toolbar) {
-
$wp_toolbar->remove_node('wp-logo');
-
$wp_toolbar->remove_node('site-name');
-
$wp_toolbar->remove_node('updates');
-
$wp_toolbar->remove_node('comments');
-
$wp_toolbar->remove_node('new-content');
-
$wp_toolbar->remove_node('top-secondary');
-
}
-
add_action('admin_bar_menu', 'my_edit_toolbar', 999);
Add/remove the line/s in the code above that correspond to the menu item/s that you would like to keep or discard.
The node ID's (for instance ‘wp-logo’ in the example code above) can be found in the HTML source code of any WordPress page with a Toolbar. Find the list items that have ID's that start with "wp-admin-bar-". For example, the list item ID for the WordPress Logo on the left in the Toolbar is "wp-admin-bar-wp-logo":
<li id="wp-admin-bar-wp-logo" class="menupop"> … </li>
Remove "wp-admin-bar-" from the list item ID to get the node ID. Hence, in this example the node ID is "wp-logo".
Please sign in to leave a comment.
Comments
0 comments