Develop

WordPress: Rename the default “Posts” to “News” or something else

A little lesson in Client love

I’m a huge advocate for “Client Centric UX”. What I mean by that is focusing as much on the client’s user experience as we do on their target market’s user experience. Having a simple to use WordPress admin goes right along with this concept. Not everyone is familiar with WordPress…shocking, I know. Furthermore, there are a lot of people who are fairly tech-savvy but have no concept of what a “blog” does or what a “post” is.

Rename Post

[fig 1.0 post]

For this reason, I almost always rename the default “post” post type to something else. Why would I leave my client a menu item that says “Posts” when they are adding news updates, or portfolio items? When labels are not intuitive, they cause confusion…which in turn can lead to a slower learning curve for your poor, poor clients. Really, for your poor, poor self…because you know who they are going to call for instruction.

Note: I’m a huge fan of custom post types, but sometimes those aren’t even necessary. If you are only needing one type of post, just rename what you already have setup with this simple code.

Solution

Changing the “Posts” menu label involves changing the menu item itself, as well as the post object labels. In the example below we are changing “Posts” to “News”. You can, of course, change “Posts” to anything you want…just replace every instance of “News” in the code below with your desired label. All you need to do is paste this into your theme’s functions.php file.

function revcon_change_post_label() {
	global $menu;
	global $submenu;
	$menu[5][0] = 'News';
	$submenu['edit.php'][5][0] = 'News';
	$submenu['edit.php'][10][0] = 'Add News';
	$submenu['edit.php'][16][0] = 'News Tags';
}
function revcon_change_post_object() {
	global $wp_post_types;
	$labels = &$wp_post_types['post']->labels;
	$labels->name = 'News';
	$labels->singular_name = 'News';
	$labels->add_new = 'Add News';
	$labels->add_new_item = 'Add News';
	$labels->edit_item = 'Edit News';
	$labels->new_item = 'News';
	$labels->view_item = 'View News';
	$labels->search_items = 'Search News';
	$labels->not_found = 'No News found';
	$labels->not_found_in_trash = 'No News found in Trash';
    $labels->all_items = 'All News';
    $labels->menu_name = 'News';
    $labels->name_admin_bar = 'News';
}

add_action( 'admin_menu', 'revcon_change_post_label' );
add_action( 'init', 'revcon_change_post_object' );

Note:

Best practice would be to paste the above code into a functionality plugin so this travels with you no matter what theme you are using (this of course depends on the situation and the client/user). To learn more about functionality plugins, there is a good article by Justin Tadlock and also another over at WPCandy.

{ 65 Comments }

  1. Hi. Thank you for providing this code. It looks like it will do what I want it to do… I’m adding this to functions.php in a child theme of the Enfold parent theme and am getting the following error:

    Parse error: syntax error, unexpected ‘$menu’ (T_VARIABLE)

  2. Flo

    That’s a sublime piece of code I have to admit. Thank you a lot.
    However, not knowing anything about php, I put right at the bottom of functions.php file as it has 2200lines of code already. It looks allright so far, but is it the right place?
    https://www.dropbox.com/s/mhjk2lt37j2xy3s/functions.php?dl=0

    Also, I would be very interested in renaming portfolio which corresponds to “products” for my client. Would you be kind enough to tell me how to do it please?

    It’s great to get posts like yours. As a non developer I tend to add loads of plugins to achieve something and I just hate it, but I have no choice. Thanks again.

    • Chris Perryman

      Hi Flo! Yes, you put the code in the right place. As far as renaming Portfolio, that could get a little messy…I can see in your functions.php file that there are a lot of features setup to run with the Portfolio post type, so you want to be careful that renaming doesn’t break any of that – make sure you save a good backup of your theme before you try anything.

      Somewhere in your theme (though it’s not in functions.php, I looked) there should be a registration of the post type. I would run a search on the entire theme folder for this “register_post_type”. You should find a function that starts with this pattern:

      < ?php register_post_type( $post_type, $args ); ?>

      Where $post_type should say ‘portfolio’ or something with the word portfolio in it. That is the section of code that controls what the naming format is.

      Within that function I would try changing the “menu_name” line to equal “Products” instead of “Portfolio” – but I wouldn’t change anything else or you will most likely break a lot of things.

  3. So helpful, and saves me from having users of my theme having to install an admin menu editing plugin. One thing left out of revcon_change_post_label() is categories. I found the index by guessing

    $submenu[‘edit.php’][15][0] = ‘News Categories’;

    • Chris Perryman

      Thanks for your input on the categories!

  4. Joel

    Thanks for this article! Very helpful.

    Just one very nit-picky thing for other people using this snippet.

    You have the template as “News”. This word is both singular and plural, so using a find and replace requires me to go in and append “s” on many of them. If it were singular word, like post, I could find/replace the word “post”, and the “s” would be preserved.

    • Chris Perryman

      True, but for the sake of clarity and since the article has already been named and indexed I will leave it as is. It’s a minor inconvenience ;)

    • If you want to handle all the singular/plural naming, and move the code to a plugin, and use a class so there are no function name conflicts, you could do something like this:

      plural;
      $submenu[‘edit.php’][5][0] = $this->plural;
      $submenu[‘edit.php’][10][0] = ‘Add ‘ . $this->singular;
      $submenu[‘edit.php’][16][0] = $this->singular . ‘ Tags’;
      }

      // ———————————————————————–

      /**
      * Change Post Object
      */
      public function change_post_object()
      {
      global $wp_post_types;

      $labels = &$wp_post_types[‘post’]->labels;

      $labels->name = $this->plural;
      $labels->singular_name = $this->singular;
      $labels->add_new = ‘Add ‘ . $this->singular;
      $labels->add_new_item = ‘Add ‘ . $this->singular;
      $labels->edit_item = ‘Edit ‘ . $this->singular;
      $labels->new_item = ‘New ‘ . $this->singular;
      $labels->view_item = ‘View ‘ . $this->singular;
      $labels->search_items = ‘Search ‘ . $this->plural;
      $labels->not_found = ‘No ‘ . $this->plural . ‘ found’;
      $labels->not_found_in_trash = ‘No ‘ . $this->plural . ‘ found in Trash’;
      $labels->all_items = ‘All ‘ . $this->plural;
      $labels->menu_name = $this->plural;
      $labels->name_admin_bar = $this->singular;
      }

      // ———————————————————————–

      }

      new rename_posts;

{ Respond }

Leave a response