简体   繁体   English

将“发布”重命名为“其他”

[英]Renaming “Post” to Something Else

Thanks for your time. 谢谢你的时间。

I want to have the WordPress dashboard treat Posts (vanilla, not custom post types or anything) exactly as normal, but to replace the word with something else. 我想让WordPress仪表板完全正常地处理帖子(香草,而不是自定义帖子类型或任何东西),但要用其他东西替换这个词。 I've tried plugins that claim to do this and they replace it in some locations but not others. 我已经尝试过声称可以执行此操作的插件,并且它们会在某些位置替换它而不是其他位置。

The hardest location to change has been at "view all posts" where the word stubbornly refuses to change from "Posts" at the title even with site-wide text replacement via plugin. 最难改变的地方是“查看所有帖子”,即使通过插件替换网站范围的文字,这个词固执地拒绝改变标题中的“帖子”。

What is the correct way to inform WordPress that I want to call Posts by a different name? 通知WordPress我想用其他名称调用帖子的正确方法是什么?

Put this in your functions.php file (obviously change "News Articles" to whatever you want the post name to be): 把它放在你的functions.php文件中(显然将“新闻文章”改为你想要的帖子名称):

// Function to change "posts" to "news" in the admin side menu
function change_post_menu_label() {
    global $menu;
    global $submenu;
    $menu[5][0] = 'News Articles';
    $submenu['edit.php'][5][0] = 'News Articles';
    $submenu['edit.php'][10][0] = 'Add News Article';
    $submenu['edit.php'][16][0] = 'Tags';
    echo '';
}
add_action( 'admin_menu', 'change_post_menu_label' );
// Function to change post object labels to "news"
function change_post_object_label() {
    global $wp_post_types;
    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'News Articles';
    $labels->singular_name = 'News Article';
    $labels->add_new = 'Add News Article';
    $labels->add_new_item = 'Add News Article';
    $labels->edit_item = 'Edit News Article';
    $labels->new_item = 'News Article';
    $labels->view_item = 'View News Article';
    $labels->search_items = 'Search News Articles';
    $labels->not_found = 'No News Articles found';
    $labels->not_found_in_trash = 'No News Articles found in Trash';
}
add_action( 'init', 'change_post_object_label' );

And if you are worried about translation (based on the comments to your question), just add the appropriate __( 'News Articles', 'my-text-domain' ); 如果您担心翻译(根据您的问题的评论),只需添加适当的__( 'News Articles', 'my-text-domain' ); function for each item... 每个项目的功能......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM