Write your own WordPress plugin to rename Posts

Watch out! This tutorial is over 6 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

Quite often when building  a WordPress website you might want to use the Post object to represent something else, for example, a business, a piece of art, a machine etc. So when the editors login, you want them to “Add New Machine”, “Edit Machine” and so on, yes?

This very website uses “Tutorials” rather than “Posts” in the backend, making it much easier for regular editors to navigate. This can be done in several ways, including renaming the menu items with a plugin or including functions in functions.php to override the strings (although you’ll need a combination of both to achieve the full effect).

But how about creating our own small plugin to handle this functionality completely? Use the following as a template for your own plugin and rename the file to be the same name as the class eg. chg_Posts_to_Machine.php. Be sure you have read this post first.

Upload this file to the wp-content/plugins directory and be sure to activate it via the WP Dashboard.

<?php
/*
Plugin Name: Rename Posts
Description: Rename built in posts to be called machines
Version: 1.0
Author: Paul Scollon
*/

// Not a WordPress context? Stop.
! defined( 'ABSPATH' ) and exit;


add_action( 'init', array ( 'chg_Posts_to_Machine', 'init' ) );
add_action( 'admin_menu', array ( 'chg_Posts_to_Machine', 'admin_menu' ) );

class chg_Posts_to_Machine
{
    public static function init()
    {
        global $wp_post_types;
        $labels = &$wp_post_types['post']->labels;
        $labels->name = 'Machines';
        $labels->singular_name = 'Machine';
        $labels->add_new = 'Add Machine';
        $labels->add_new_item = 'Add Machine';
        $labels->edit_item = 'Edit Machine';
        $labels->new_item = 'Machine';
        $labels->view_item = 'View Machine';
        $labels->search_items = 'Search Machines';
        $labels->not_found = 'No Machines found';
        $labels->not_found_in_trash = 'No Machines found in trash';
        $labels->name_admin_bar = 'Machine';
    }

    public static function admin_menu()
    {
        global $menu;
        global $submenu;
        $menu[5][0] = 'Machine';
        $submenu['edit.php'][5][0] = 'Edit Machine';
        $submenu['edit.php'][10][0] = 'Add NEW Machine';
    }
}
?>