开发者

Change menu items labels in wordpress admin area?

Is there a way to change the labels of the menu items inside the admin area? Like when you register a new custom post type when you can specify every label开发者_运维知识库 for it, but for the default menu items.

Thanks in advance!


add_filter( 'gettext', 'change_post_to_article' );
add_filter( 'ngettext', 'change_post_to_article' );

function change_post_to_article( $translated ) 
{  
    $translated = str_replace( 'Post', 'Article', $translated );
    $translated = str_replace( 'post', 'article', $translated );
    return $translated;
}

There is another way to do this, for more info check this answer.


Best Solution is this, just write in your functions.php or plugin file

function change_post_menu_label() {
    global $menu;
    global $submenu;
    $menu[70][0] = 'Articles';
    $submenu['user-edit.php'][5][0] = 'Articles';
    $submenu['user-edit.php'][10][0] = 'Add Articles';
    echo '';
}
function change_post_object_label() {
        global $wp_post_types;
        $labels = &$wp_post_types['users']->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' );


FYI, newer reference for that code at my current company's blog: http://www.get10up.com/blog/2011/03/customizing-wordpress-admin/

You can use str ireplace in PHP5 to avoid two calls.


// Rename Plugins to Apps Store

function rename_plugin_menu() {  
    global $menu;       
    $menu[65][0] = 'Apps Store'; // Change Users to Customers main id
}  
add_action( 'admin_menu', 'rename_plugin_menu' );  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜