我已将帖子更改为新闻,这是wordpress的默认帖子类型。但我也想改变网址。意思是当我将鼠标悬停在菜单上时,该网址就像http://www.example.com/blog/
我想改为http://www.example.com/News/。我是否可以更改为更改默认帖子类型名称而编写的代码(发布到新闻)。
我使用代码更改了名称
function revcon_change_post_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News Tags';
echo '';
}
function revcon_change_post_object() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'News';
$labels->singular_name = 'News';
$labels->add_new = 'Add News';
$labels->add_new_item = 'Add News';
$labels->edit_item = 'Edit News';
$labels->new_item = 'News';
$labels->view_item = 'View News';
$labels->search_items = 'Search News';
$labels->not_found = 'No News found';
$labels->not_found_in_trash = 'No News found in Trash';
$labels->all_items = 'All News';
$labels->menu_name = 'News';
$labels->name_admin_bar = 'News';
}
add_action( 'admin_menu', 'revcon_change_post_label' );
add_action( 'init', 'revcon_change_post_object' );
答案 0 :(得分:1)
您想要实现的目标可以通过更多" Wordpressy"使用Custom Post Types(a.k.a CPT' s)的复杂方式。您可以完全控制自己创建的自定义帖子类型,包括要显示的URL。
如果您不想自己编写CPT代码,可以尝试使用插件:https://wordpress.org/plugins/custom-post-type-ui/