So I am renaming my "Posts" in WordPress backend to "News" and was able to use the code (thanks to Chris Perryman) added to my functions.php file but I would also like to change the default dashicon as well to: dashicons-media-document instead of the default "dashicons-admin-post"
I have tried adding: $labels->icon_url = 'dashicons-media-document';
but that doesn't work for some reason or other?
Thank-you in advance for any help!
function revcon_change_post_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News Tags';
}
function revcon_change_post_object() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'News';
$labels->singular_name = 'News';
$labels->add_new = 'Add News';
$labels->add_new_item = 'Add News';
$labels->edit_item = 'Edit News';
$labels->new_item = 'News';
$labels->view_item = 'View News';
$labels->search_items = 'Search News';
$labels->not_found = 'No News found';
$labels->not_found_in_trash = 'No News found in Trash';
$labels->all_items = 'All News';
$labels->menu_name = 'News';
$labels->name_admin_bar = 'News';
}
add_action( 'admin_menu', 'revcon_change_post_label' );
add_action( 'init', 'revcon_change_post_object' );
I would like to be able to just add a simple line or two of code to my custom-themes' function.php so this will all get updated on a new install.
Use CSS
function bks_replace_admin_menu_icons_css() {
?>
<style>
.dashicons-admin-post:before {
font-family: "dashicons";
content: "\f497" !important;
}
</style>
<?php
}
add_action( 'admin_head', 'bks_replace_admin_menu_icons_css' );
Code goes inside functions.php
file.