Skip to content

Instantly share code, notes, and snippets.

@chuckreynolds
Created September 15, 2015 22:11
Show Gist options
  • Save chuckreynolds/527537909ce945aa1382 to your computer and use it in GitHub Desktop.
Save chuckreynolds/527537909ce945aa1382 to your computer and use it in GitHub Desktop.
Change WordPress POSTS menu name, submenu names, and dashicon in the admin menu and associated labels.
<?php
/**
* Change the name of the main Posts menu and submenus
* and change the dashicon of the main menu item
*/
function chuck_change_post_type_menu() {
global $menu;
global $submenu;
$menu[5][0] = 'Content Hub';
$submenu['edit.php'][5][0] = 'Content';
$submenu['edit.php'][10][0] = 'Add Content';
$submenu['edit.php'][15][0] = 'Content Categories';
$submenu['edit.php'][16][0] = 'Content Tags';
foreach ( $menu as $key => $val ) {
if ( 'Content Hub' == $val[0] ) {
$menu[$key][6] = 'dashicons-welcome-write-blog';
}
}
}
add_action( 'admin_menu', 'chuck_change_post_type_menu' );
/**
* Change the all the Post type meta labels too
*/
function chuck_change_post_type_labels() {
global $wp_post_types;
$postLabels = $wp_post_types['post']->labels;
$postLabels->name = 'Content Hub';
$postLabels->singular_name = 'Content';
$postLabels->add_new = 'Add Content';
$postLabels->add_new_item = 'Add Content';
$postLabels->edit_item = 'Edit Content';
$postLabels->new_item = 'Content';
$postLabels->view_item = 'View Content';
$postLabels->search_items = 'Search the Content Hub';
$postLabels->not_found = 'Nothing found in Content Hub';
$postLabels->not_found_in_trash = 'No Content found in Trash';
}
add_action( 'init', 'chuck_change_post_type_labels' );
/**
* For Reference ONLY: to change the posts menu dashicon using
* admin css instead of running through the array.
* I don't personally like this method but it does work.
* dashicon content: "\f119" is dashicons-welcome-write-blog
*/
/*
function chuck_change_post_type_args() {
?>
<style>
#adminmenu #menu-posts div.wp-menu-image::before {
content: "\f119";
}
</style>
<?php
}
add_action( 'admin_head', 'chuck_change_post_type_args' );
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment