Renaming WordPress Default Admin Menu Names and Object Labels

| 4 Comments

I am currently working on a project in which I needed to alter the default wording in the admin area of WordPress. Specifically, I needed to rename the item names in the posts menu as well as the object labels in the posts and categories edit pages.

Aaron Summers provided the recipe for changing the posts menu names and object labels. Add the following to your theme’s functions.php to rename ‘Posts’ to ‘Products’:

// Change the menu item labels
function change_post_menu_label() {
	global $menu;
	global $submenu;
	$menu[5][0] = 'Products';
	$submenu['edit.php'][5][0] = 'Products';
	$submenu['edit.php'][10][0] = 'Add Products';
	$submenu['edit.php'][15][0] = 'Products Category'; // Change name for categories
	$submenu['edit.php'][16][0] = 'Labels'; // Change name for tags
	echo '';
}
add_action( 'admin_menu', 'change_post_menu_label' );

// Change the post object labels
function change_post_object_label() {
	global $wp_post_types;
	$labels = &$wp_post_types['post']->labels;
	$labels->name = 'Products';
	$labels->singular_name = 'Product';
	$labels->add_new = 'Add Products';
	$labels->add_new_item = 'Add Product';
	$labels->edit_item = 'Edit Product';
	$labels->new_item = 'Product';
	$labels->view_item = 'View Product';
	$labels->search_items = 'Search Products';
	$labels->not_found = 'No Products found';
	$labels->not_found_in_trash = 'No Products found in Trash';
}
add_action( 'init', 'change_post_object_label' );

Changing the Taxonomy Labels

Moreover, Aaron’s post also gave me a hint as to where I could find a way to change the default taxonomy object labels. Namely around line 396 (WP 3.6) in wp-includes/taxonomy.php. Add the following to your theme’s functions.php and rename accordingly:

function change_tax_object_label() {
	global $wp_taxonomies;
	$labels = &$wp_taxonomies['category']->labels;
	$labels->name = __('Your Taxonomy Names', 'theme_namespace');
	$labels->singular_name = __('Your Taxonomy Name', 'theme_namespace');
	$labels->search_items = __('Search Your Taxonomy Names', 'theme_namespace');
	$labels->all_items = __('All Your Taxonomy Names', 'theme_namespace');
	$labels->parent_item = __('Your Parent Taxonomy Name', 'theme_namespace');
	$labels->parent_item_colon = __('Your Parent Taxonomy Name:', 'theme_namespace');
	$labels->edit_item = __('Edit Your Taxonomy Name', 'theme_namespace');
	$labels->view_item = __('View Your Taxonomy Name', 'theme_namespace');
	$labels->update_item = __('Update Your Taxonomy Name', 'theme_namespace');
	$labels->add_new_item = __('Add Your Taxonomy Name', 'theme_namespace');
	$labels->new_item_name = __('Your New Taxonomy Name', 'theme_namespace');
}
add_action( 'init', 'change_tax_object_label' );

Please note, that I have made the thing translatable, hence remember to replace 'theme_namespace' with your … well, theme’s namespace.

The above code works for categories, but you can make it work for tags as well. Please refer to the afore mentioned wp-includes/taxonomy.php to find all the available label names.

Author: Morten Brunbjerg Bech

Webdesigner, front end udvikler og bibliotekar. Arbejder primært med udvikling og design af Horsens Kommunes Bibliotekers webløsninger og er specialist i semantisk strukturering af webdokumenter samt Adobe Photoshop og Illustrator.

4 Comments

  1. I tried to add the “change taxonomy labels” function to the functions.php file of my child theme (child of twenty eleven) and it didn’t work … White Screen of Death.

    `function change_tax_object_label() {
      global $wp_taxonomies;
      $labels = &$wp_taxonomies[‘category’]->labels;
      $labels->name = __(‘Board or Committee’, ‘hopetheme-minutes’);
      $labels->singular_name = __(‘Board or Committee’, ‘hopetheme-minutes’);
      $labels->search_items = __(‘Search Boards and Committees’, ‘hopetheme-minutes’);
      $labels->all_items = __(‘All Boards and Committees’, ‘hopetheme-minutes’);
      $labels->parent_item = __(‘Boards and Committees’, ‘hopetheme-minutes’);
      $labels->parent_item_colon = __(‘Boards and Committees:’, ‘hopetheme-minutes’);
      $labels->edit_item = __(‘Edit Board or Committee’, ‘hopetheme-minutes’);
      $labels->view_item = __(‘View Board or Committee’, ‘hopetheme-minutes’);
      $labels->update_item = __(‘Update Board or Committee’, ‘hopetheme-minutes’);
      $labels->add_new_item = __(‘Add Board or Committee’, ‘hopetheme-minutes’);
      $labels->new_item_name = __(‘New Board or Committee’, ‘hopetheme-minutes’);
    }
    add_action( ‘init’, ‘change_tax_object_label’ );`

    Did I do something wrong?

    • That looks correct to me.

      If you get a White Screen of Death, however, try switching on display_errors in your server’s php.ini file, then restart the server. If you don’t have access to the php.ini file, you may be able to do the same with .htaccess. Then your browser should display an error so you will be able to see what is going wrong.

  2. Hi Morten,

    I’d like to rename a label into my admin bar that was imported or just “created” in a second moment by my premium theme, clicking on this label I’m able to go to the options theme menu. So in few words I’d like to customize this label.
    I hope you can help me.

  3. Well, I was having a need to change more menus and even hide some, so I created a plugin to do just that. It can change labels, reorder, change icon, you name it. Check it out (feedback is much appreciated): http://codecanyon.net/item/wp-admin-menu-manager/9520160?ref=732

Leave a Reply