有没有办法更改管理区域内菜单项的标签?就像你注册新的自定义帖子类型时一样, 可以为其指定每个标签, 但可以指定默认菜单项。
提前致谢!
#1
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;
}
还有另一种方法, 有关更多信息, 请查看此答案。
#2【更改WordPress管理区域中的菜单项标签()】最好的解决方案是这样, 只需在你的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' );
#3仅供参考, 我当前公司的博客中有关该代码的更新参考:http://www.get10up.com/blog/2011/03/customizing-wordpress-admin/
你可以在PHP5中使用strireplace避免两次调用。
#4//将插件重命名为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' );
推荐阅读
- 更改连续类别页面上的帖子数(WordPress)
- 通过子主题更改自定义帖子类型的标签
- 论异步编程的正确姿势(十个接口的活现在只需要一个接口就能搞定!)
- #yyds干货盘点# springboot使用@Async实现异步调用
- 图解MongoDB集群部署原理
- MongoDB学习笔记MongoDB索引那点事
- 大数据SQL优化之数据倾斜解决案例全集
- 如何保证缓存与数据库双写时的数据一致性()
- Java 16 中新增的 Stream 接口的一些思考