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. Nice! Thanks for sharing!

  2. Thank you for this, your AWESOME!! for sharing it.

    I went on and found this:
    You can use

    https://codex.wordpress.org/Function_Reference/get_post_type_object

    And in the latest version of WordPress the menu is renamed so its no longer an issue, and you dont have to add revcon_change_post_label().

    My need was that I wanted to change the menu icon of the post type so this is what I did, if it might help anyone who is trying to do the same thing

    function revcon_change_post_object() {
    $get_post_type = get_post_type_object(‘post’);
    $labels = $get_post_type->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’;
    //Change menu icon
    $get_post_type->menu_icon = ‘dashicons-microphone’;
    }
    add_action( ‘init’, ‘revcon_change_post_object’ );

    • Chris Perryman

      Great! Thanks for sharing :)

    • piotr

      I am unable to change the icon with

      $get_post_type->menu_icon = ‘dashicons-microphone’;

      i get an error:
      Warning: Creating default object from empty value in /Applications/MAMP/htdocs/dbarlicki.dev/wp-content/themes/KropkiKreski/functions.php on line 485

      would love to make it work!

    • piotr

      OK, got it working, the problem was copying from comments – some change in codin og ” ‘ “

    • Chris Perryman

      Ah, yes….gotta watch out for those! Glad you got it working.

  3. Lin

    Anyway is there a way to add prefix to the slug ?

    • Chris Perryman

      Can you clarify your question? Do you mean you want to adjust the permalink structure for the post URLs? Like: revelationconcept.com/blog/post-name ? Where you would be “adding” /blog/ ?

      If so, you don’t need to do that in code…you can add that in your settings under the permalink page. Something like this: /blog/%postname%

  4. Lebanon Raingam

    Thank you so much @Chris, I’ll try. Hopefully, I’ll be able to understand what’s explained there :)

  5. Lebanon Raingam

    Hi Chris Perryman,

    This is great. Is there also a way to rename the “Categories” to “Authors”? Can you please help? Thanks.

    Lebanon Raingam

    • Chris Perryman

      I wrote a quick tutorial for you on how you can do this: http://revelationconcept.com/wordpress-rename-default-category-taxonomy/.

    • Chris Perryman

      Please let me know if you need more clarification on that…or if you run into any issues setting it up.

    • Lebanon Raingam

      Thank you so much @Chris, I’ll try. Hopefully, I’ll be able to understand what’s explained there :)

{ Respond }

Leave a response