We can easily change the labels of menu items in the WordPress admin dashboard.
For example, a company website typically uses the “Posts” area for the company blog.
In this case, it might be a good idea to rename the menu item from “Posts” to “Blog” to make it clearer to webmasters:
/**
* Renames admin menu items
*/
function notesontech_rename_admin_menu_items() {
global $menu;
// Rename "Posts" to "Blog".
$menu[5][0] = 'Blog';
}
add_action( 'admin_menu', 'notesontech_rename_admin_menu_items' );
This PHP code can be added to the functions.php
file of the theme or to another theme configuration file if one exists.
To rename submenu items, we simply need to add the global $submenu
variable as well:
/**
* Renames admin menu items
*/
function notesontech_rename_admin_menu_items() {
global $menu;
global $submenu;
// Rename "Posts" to "Blog".
$menu[5][0] = 'Blog';
// Rename "All Posts" to "All Blog Posts".
$submenu['edit.php'][5][0] = 'All Blog Posts';
}
add_action( 'admin_menu', 'notesontech_rename_admin_menu_items' );
We can use this function to handle all the adjustments of the admin menu items in one place.