$wp_post_types
is a global array that holds post_type
objects, which in turn have a labels
property.
You can change $wp_post_types[$post_type]->labels
after the parent theme has set the CPT.
Add higher priority to init
hook.
Add the following code in your theme’s functions.php
file.
For more information, check out the codex article on get_post_type_object
.
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['portfolio']->labels;
$labels->name="Property";
$labels->singular_name="Property";
$labels->add_new = 'Add Property';
$labels->add_new_item = 'Add Property';
$labels->edit_item = 'Edit Property';
$labels->new_item = 'Property';
$labels->all_items="All Properties";
$labels->view_item = 'View Property';
$labels->search_items="Search Property";
$labels->not_found = 'No Property found';
$labels->not_found_in_trash="No Property found in Trash";
}
add_action( 'init', 'change_post_object_label', 999 );
Add following code in functions.php
to replace main menu label from sidebar
function change_post_menu_label() {
global $menu;
//print_r($menu); Print menus and find out the index of your custom post type menu from it.
$menu[27][0] = 'Bacons'; // Replace the 27 with your custom post type menu index from displayed above $menu array
}
add_action( 'admin_menu', 'change_post_menu_label' );
Add following code in functions.php
for adding image to admin sidebar CPT menu
add_action('admin_head', 'change_CPT_icon');
function change_CPT_icon() {?>
<style>
#menu-posts-portfolio .wp-menu-image { background: url('<?php echo get_bloginfo('template_directory').'/includes/images/new-image.png';?>') no-repeat 5px 5px transparent !important; }
</style>
<?php
}