Changing Posts Menu Label in WordPress

June 24, 2017

In this case, renaming it to News.

What does this do exactly?

Let’s say you have a client, and to make everything clear or less confusing, renaming Posts to News is easier to explain on their documentation.

Add this code on your current theme’s functions.php file.

function 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 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', 'change_post_label' );
add_action( 'init', 'change_post_object' );
Get In Touch

Email: [email protected]


CAPTCHA image

This helps us prevent spam, thank you.



Categories