Change entities names in wordpress

how to change names of elements in wordpress admin panel? For example change “Posts” on “Products”, with all forms, existing anywhere. I know, that when I create my own taxonomy, I can set all the forms of it’s name. May be I can make something like that for general names of entities like Posts and Pages?

Related posts

Leave a Reply

1 comment

  1. You can change the name in the init action hook, like so:

    function change_post_object_label() {
        global $wp_post_types;
    
        $labels = &$wp_post_types['post']->labels;
        $labels->name = 'Products';
        $labels->singular_name = 'Product';
        $labels->add_new = 'Add Product';
        $labels->add_new_item = 'Add Product';
        $labels->edit_item = 'Edit Products';
        $labels->new_item = 'Product';
        $labels->view_item = 'View Product';
        $labels->search_items = 'Search Products';
        $labels->not_found = 'No Products found';
        $labels->not_found_in_trash = 'No Products found in Trash';
    }
    add_action( 'init', 'change_post_object_label' );
    

    To change the Menu Label though you gotta use a separate hook: admin_menu

    function edit_menu_items() {
        global $menu;
        global $submenu;
    
        $menu[5][0] = 'Products';
        $submenu['edit.php'][5][0] = 'Products';
        $submenu['edit.php'][10][0] = 'Add Product';
    }
    add_action('admin_menu', 'edit_menu_items');