感谢您抽出时间。
我想让WordPress的面板把帖子(香草的,不是自定义的帖子类型或任何东西)完全像正常的一样处理,但用其他东西代替这个词。我尝试过声称可以做到这一点的插件,它们在一些地方取代了它,但在其他地方却没有。
最难更改的位置是"查看所有帖子",即使通过插件在整个网站范围内替换文本,标题中的"帖子"一词也顽固地拒绝更改。
什么是正确的方式来通知WordPress我想用不同的名字来称呼Posts?
将其放在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' );
如果你担心翻译(根据对问题的评论),只需为每个项目添加适当的__( 'News Articles', 'my-text-domain' );
函数。。。