How To Change Post Labels In WordPress Admin Area?

Few weeks back we discussed about a plugin that changes WordPress posts labels to articles. Now in this tutorial we will learn how you can edit and use your own names in WordPress post labels. By saying admin post labels we mean the ext post(s) present anywhere in admin area like Dashboard -> Posts, Posts -> All Posts, and Add New Post, Edit Posts etc etc.

How To Edit WordPress Post Labels?

Open your theme’s function.php file and paste the following code changing YourLabel(s) to Article(s), News or whatever you like naming them:

<?php
function change_post_menu_text() {
global $menu;
global $submenu;

$menu[5][0] = ‘YourLabel’;

$submenu[‘edit.php’][5][0] = ‘All YourLabels’;
$submenu[‘edit.php’][10][0] = ‘Add YourLabel’;
$submenu[‘edit.php’][16][0] = ‘Tags’;
}

add_action( ‘admin_menu’, ‘change_post_menu_text’ );

/*
* Changing the post labels
*/
function change_post_labels() {
global $wp_post_types;

$postLabels = $wp_post_types[‘post’]->labels;
$postLabels->name = ‘YourLabels’;
$postLabels->singular_name = ‘YourLabel’;
$postLabels->add_new = ‘Add YourLabel’;
$postLabels->add_new_item = ‘Add YourLabel’;
$postLabels->edit_item = ‘Edit YourLabel’;
$postLabels->new_item = ‘YourLabel’;
$postLabels->view_item = ‘View YourLabel’;
$postLabels->search_items = ‘Search YourLabels’;
$postLabels->not_found = ‘No YourLabels found’;
$postLabels->not_found_in_trash = ‘No YourLabels found in Trash’;
}
add_action( ‘init’, ‘change_post_labels’ );

?>

Example: In the following example we have changed ‘Post’ Label to ‘Webcast’:

<?php

function change_post_menu_text() {
global $menu;
global $submenu;

$menu[5][0] = ‘Webcasts’;

$submenu[‘edit.php’][5][0] = ‘All Webcasts’;
$submenu[‘edit.php’][10][0] = ‘Add Webcast’;
$submenu[‘edit.php’][16][0] = ‘Tags’;
}

add_action( ‘admin_menu’, ‘change_post_menu_text’ );

/*
* Changing the post labels
*/

function change_post_labels() {
global $wp_post_types;

$postLabels = $wp_post_types[‘post’]->labels;
$postLabels->name = ‘Webcasts’;
$postLabels->singular_name = ‘Webcast’;
$postLabels->add_new = ‘Add Webcast’;
$postLabels->add_new_item = ‘Add Webcast’;
$postLabels->edit_item = ‘Edit Webcast’;
$postLabels->new_item = ‘Webcast’;
$postLabels->view_item = ‘View Webcast’;
$postLabels->search_items = ‘Search Webcasts’;
$postLabels->not_found = ‘No Webcasts found’;
$postLabels->not_found_in_trash = ‘No Webcasts found in Trash’;
}
add_action( ‘init’, ‘change_post_labels’ );

?>

To make things more easy and so that you won’t miss your theme edits in updates we suggest you to use this plugin for easily adding and managing all custom hacks which you have added in your website.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.