Develop

WordPress: Rename Default Category Taxonomy

After my post on Renaming the default “Posts” post type in WordPress to something else, I’ve gotten some follow up questions on renaming taxonomies as well. Here is a quick tutorial on how you can rename the default WordPress taxonomies (tags/categories).

Solution

Similar to renaming the post type, we need to tackle two areas: the menu item label, and the post object labels. In this example, I’m going to rename the default “Category” to “Authors”. You can rename “Category” to anything you want, just replace every instance of Author/Authors in my code below.

Changing Admin Menu

First, let’s rename the menu item in the WordPress admin. You can copy this code into your functions.php file, or into a custom functionality plugin.

function revcon_change_cat_label() {
	global $submenu;
	$submenu['edit.php'][15][0] = 'Authors'; // Rename categories to Authors
}
add_action( 'admin_menu', 'revcon_change_cat_label' );

Note: to apply these changes to tags, use $submenu['edit.php'][16][0] = 'Author Tags';.

Changing Object Labels

Next, let’s update the other labels throughout the admin (meta boxes etc.), you can paste this code directly below the code for renaming the menu label.

function revcon_change_cat_object() {
	global $wp_taxonomies;
	$labels = &$wp_taxonomies['category']->labels;
	$labels->name = 'Author';
	$labels->singular_name = 'Author';
	$labels->add_new = 'Add Author';
	$labels->add_new_item = 'Add Author';
	$labels->edit_item = 'Edit Author';
	$labels->new_item = 'Author';
	$labels->view_item = 'View Author';
	$labels->search_items = 'Search Authors';
	$labels->not_found = 'No Authors found';
	$labels->not_found_in_trash = 'No Authors found in Trash';
    $labels->all_items = 'All Authors';
    $labels->menu_name = 'Author';
    $labels->name_admin_bar = 'Author';
}
add_action( 'init', 'revcon_change_cat_object' );

Note: to apply these changes to the tag taxonomy, change:
$labels = &$wp_taxonomies['category']->labels;
to…
$labels = &$wp_taxonomies['post_tag']->labels;

Conclusion

This code provides a quick, simple adjustment to the WordPress admin that can be very intuitive for clients and users! It’s always best to call something what it is, or at least what it’s intended to be used as, so that you have a seamless UX and aren’t spending all day providing client support ;)

{ 9 Comments }

  1. Thanks !

  2. Hi, Chris, would you know how to remove the hierarchy from the default Categories?

    Say, I created a custom taxonomy, I could easily define hierarchy to be hierarchical’ => false and get rid of it.

    But how do I filter through the default and remove the hierarchy feature? Thanks.

    Again, how do I remove the default Category feature, say I didn’t need it.

    Thanks.

  3. Breanna

    Thank you!!

    I am trying to change both the category label (to Content) and the tag label (to Type).
    Besides changing “Note: to apply these changes to tags, use $submenu[‘edit.php’][16][0] = ‘Author Tags’;.” and “$labels = &$wp_taxonomies[‘post_tag’]->labels;” is there something else that is supposed to be updated? When I use both I get a major error, saying it’s been used above.

    Am I to update “revcon_change_cat_label()” as well?

  4. Perfect, that works like a charm. This has been very useful for me. Thanks!

  5. Hi, Chris, thanks for this–it works seamless. But there one area left I don’t see how to change. The Category archive itself. The title is the default Category: Category-name. In my case, I’d changed it from Category to Series, so I expected the archive itself to say Series: Series-name. How do I do that?

    In case it helps, my index.php file has this for the output:

    <?php
    the_archive_title('’, ”);
    the_archive_description(”, ”);
    ?>

    • Chris Perryman

      Hey! Great catch. So I looked at the object and while there are additional labels you can alter (besides the ones I listed) the archive title isn’t one of them. However, you can filter that with the following:

      function revcon_change_cat_title($title, $id = null) {
          if ( get_post_type($id) == 'post' ) {
              $title = sprintf( __( 'Series: %s' ), single_cat_title( '', false ) );       
          }
          return $title;
      }
      add_filter( 'get_the_archive_title', 'revcon_change_cat_title', 10, 2 );
      

{ Respond }

Leave a response