Change name and labels of default WP content types


Intermediate

This is how you can change labels for default content types of WordPress. In this example we change ‘Posts’ to ‘News’.

Here’s the PHP ¬†code to put in your functions.php

//Change posts labels
function xiong_change_post_label() {
    global $menu;
    global $submenu;
    $menu[5][0] = 'News';
    $submenu['edit.php'][5][0] = 'News articles';
    $submenu['edit.php'][10][0] = 'Add news article';
    $submenu['edit.php'][16][0] = 'Tags';
}
function xiong_change_post_object() {
    global $wp_post_types;
    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'News';
    $labels->singular_name = 'News article';
    $labels->add_new = 'Add new';
    $labels->add_new_item = 'Add new News article';
    $labels->edit_item = 'Edit News article';
    $labels->new_item = 'News article';
    $labels->view_item = 'Show News article';
    $labels->search_items = 'Search for News article';
    $labels->not_found = 'Could not found News articles';
    $labels->not_found_in_trash = 'Not even in trash can';
    $labels->all_items = 'All News articles';
    $labels->menu_name = 'News';
    $labels->name_admin_bar = 'News';
}
 
add_action( 'admin_menu', 'xiong_change_post_label' );
add_action( 'init', 'xiong_change_post_object' );