Created
June 12, 2024 15:55
-
-
Save itsamoreh/1f1078dc57cb9d86ea05b33e2f8fe3f5 to your computer and use it in GitHub Desktop.
Change default "Posts" to "News" across WordPress admin - including all labels and the dashicon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change Posts to News. | |
* | |
* @author Amor Kumar (itsamoreh) | |
*/ | |
/** | |
* Change the dashboard menu labels. | |
*/ | |
function 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'; | |
} | |
/** | |
* Change the dashboard menu icon. | |
*/ | |
function change_menu_icon() { | |
global $menu; | |
foreach ( $menu as $key => $val ) { | |
if ( 'News' == $val[0] ) { | |
$menu[$key][6] = 'dashicons-megaphone'; | |
} | |
} | |
} | |
/** | |
* Change the post object labels. | |
*/ | |
function 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 Article'; | |
$labels->edit_item = 'Edit Article'; | |
$labels->new_item = 'New Article'; | |
$labels->view_item = 'View Article'; | |
$labels->search_items = 'Search News Articles'; | |
$labels->not_found = 'No Articles found'; | |
$labels->not_found_in_trash = 'No Articles found in Trash'; | |
$labels->parent_item_colon = 'Parent Articles:'; | |
$labels->all_items = 'All News'; | |
$labels->menu_name = 'News'; | |
$labels->archives = 'News Archives'; | |
$labels->attributes = 'News Attributes'; | |
$labels->insert_into_item = 'Insert into Article'; | |
$labels->uploaded_to_this_item = 'Uploaded to this Article'; | |
$labels->filter_items_list = 'Filter Articles List'; | |
$labels->items_list_navigation = 'Articles List Navigation'; | |
$labels->items_list = 'Articles List'; | |
$labels->item_published = 'Article published.'; | |
$labels->item_published_privately = 'Article published privately.'; | |
$labels->item_reverted_to_draft = 'Article reverted to draft.'; | |
$labels->item_scheduled = 'Article scheduled.'; | |
$labels->item_updated = 'Article updated.'; | |
$labels->item_link = 'Article Link'; | |
$labels->item_link_description = 'A link to an Article.'; | |
$labels->name_admin_bar = 'News'; | |
} | |
add_action( 'admin_menu', __NAMESPACE__ . '\change_post_label' ); | |
add_action( 'admin_menu', __NAMESPACE__ . '\change_menu_icon' ); | |
add_action( 'init', __NAMESPACE__ . '\change_post_object' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment