我正在使用wordpress。任何人都可以幫助我如何在WordPress中更改管理面板菜單標籤。在Wordpress中將標籤更改爲文章
具體而言,我想要更改Posts到Articles的標籤。以及郵件管理面板中的所有實例。
請注意。
我正在使用wordpress。任何人都可以幫助我如何在WordPress中更改管理面板菜單標籤。在Wordpress中將標籤更改爲文章
具體而言,我想要更改Posts到Articles的標籤。以及郵件管理面板中的所有實例。
請注意。
以下是您需要添加到主題功能文件中的代碼。
// Replace Posts label as Articles in Admin Panel
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Articles';
$submenu['edit.php'][5][0] = 'Articles';
$submenu['edit.php'][10][0] = 'Add Articles';
echo '';
}
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'Articles';
$labels->singular_name = 'Article';
$labels->add_new = 'Add Article';
$labels->add_new_item = 'Add Article';
$labels->edit_item = 'Edit Article';
$labels->new_item = 'Article';
$labels->view_item = 'View Article';
$labels->search_items = 'Search Articles';
$labels->not_found = 'No Articles found';
$labels->not_found_in_trash = 'No Articles found in Trash';
}
add_action('init', 'change_post_object_label');
add_action('admin_menu', 'change_post_menu_label');
改編自:https://wordpress.stackexchange.com/questions/9211/changing-admin-menu-labels
您可能還需要更改$ wp_post_types ['post'] - > label(string) – guidod
在你的主題功能的文件包括這些行:以前的答案的
//Change Posts labels in sidebar admin menu
function custom_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
}
//Change Posts labels in other admin area
function custom_post_object_label() {
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 results on News';
$labels->not_found_in_trash = 'No News in Trash';
$labels->name_admin_bar = 'Add News';
}
add_action('init', 'custom_post_object_label');
add_action('admin_menu', 'custom_post_menu_label');
作者忘了,包括「$ labels-> name_admin_bar = '添加新聞'; 「串。
我能夠這樣使用post_type_labels_{$post_type}
過濾器等,以解決這樣
add_filter('post_type_labels_post', 'change_post_labels' ]);
function change_post_labels($args) {
foreach($args as $key => $label){
$args->{$key} = str_replace([ __('Posts'), __('Post') ], __('News'), $label);
}
return $args;
}
這個答案也使翻譯的支持不變。唯一值得注意的是,你可能不得不從插件運行它,因爲主題太晚了。
[更改管理員菜單標籤](http://wordpress.stackexchange.com/q/9211) –
謝謝@Pekka,我明白了。謝謝。發表回答 – Krunal