更改 WordPress 管理区域中的菜单项标签?

发布于 2024-10-05 22:14:55 字数 78 浏览 3 评论 0原文

有没有办法更改管理区域内菜单项的标签?就像当您注册新的自定义帖子类型时,您可以为其指定每个标签,但对于默认菜单项。

提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

谈情不如逗狗 2024-10-12 22:14:55
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;
}

还有另一种方法可以做到这一点,有关详细信息,请查看此答案

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.

北音执念 2024-10-12 22:14:55

最好的解决方案是这样,只需写入你的functions.php或插件文件

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' );

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' );
青萝楚歌 2024-10-12 22:14:55

仅供参考,该代码的较新参考位于我当前公司的博客中: http:// /www.get10up.com/blog/2011/03/customizing-wordpress-admin/

您可以在 PHP5 中使用 str ireplace 来避免两次调用。

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.

油饼 2024-10-12 22:14:55

// 将插件重命名为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' );  

// 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' );  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文