wordpress菜单名称重定名

[摘要]wordpress默认环境下文章页英文叫post, page,有时候,我们开拓的时候,也许并不想要这个菜单照旧显示着post,和page,也许你想要显示为其它的名称,好比“产物”,”接洽人”亦或是其它的名称!

  WordPress系统源于一个blog平台,逐步地成长到本日的这样一个成果强大的cms系统!

  尽量如此,可是wordpress默认环境下文章页英文叫post, page,有时候,我们开拓的时候,也许并不想要这个菜单照旧显示着post,和page,也许你想要显示为其它的名称,好比“产物”,”接洽人”亦或是其它的名称!

  虽然我们可以本身写一个post type,移除本来的文章范例,新建的的内容范例可以本身定名,可是其实我们尚有一个更好的要领对本来系统的内容范例菜单名称举办重定名:

  看下面的一个海外的好手的代码:

<?php
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Contacts';
$submenu['edit.php'][5][0] = 'Contacts';
$submenu['edit.php'][10][0] = 'Add Contacts';
$submenu['edit.php'][15][0] = 'Status'; // Change name for categories
$submenu['edit.php'][16][0] = 'Labels'; // Change name for tags
echo '';
}

function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'Contacts';
$labels->singular_name = 'Contact';
$labels->add_new = 'Add Contact';
$labels->add_new_item = 'Add Contact';
$labels->edit_item = 'Edit Contacts';
$labels->new_item = 'Contact';
$labels->view_item = 'View Contact';
$labels->search_items = 'Search Contacts';
$labels->not_found = 'No Contacts found';
$labels->not_found_in_trash = 'No Contacts found in Trash';
}
add_action( 'init', 'change_post_object_label' );
add_action( 'admin_menu', 'change_post_menu_label' );
To change the menu order, go with this:

// CUSTOMIZE ADMIN MENU ORDER
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php', // this represents the dashboard link
'edit.php', //the posts tab
'upload.php', // the media manager
'edit.php?post_type=page', //the posts tab
);
}
add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');
?>

  这一个代码中就是把本来的文章post的菜单名“post”变动为Contact了!

  参考资料:

  原文地点:

分享到

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9854.html