How to rename the default “Posts” to “News” or something else?

0
86
How to rename the default Posts to News or something else-01-01

DESCRIPTION:

How to rename the default “Posts” to News or Something else? Many people got confused and they don’t want to install another plugin to enable this feature.

When I develop websites or blogs for my clients, they usually say some changes, even if its doesn’t make any sense. But we need to hear our clients suggestions or queries since they are important to us. Many cases, I got suggestion to change the default WordPress “Posts” to some other names like “News”, “Stores”, “Articles”, or anything else.

Actually this is very simple code which will rename the “post” to some other names. Renaming the default WordPress posts to another name even it is a simple thing for a developer. Client always wants some different names/design from what we proposed. So lets see the solution below:

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 and Click Save.

// Convert "posts" to "News"
functionrevcon_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';
}
functionrevcon_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')

Conclusion:

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).

LEAVE A REPLY

Please enter your comment!
Please enter your name here