我创建了一个自定义帖子类型并将其隐藏
使用
register_post_type()
和一个菜单页面使用
add_menu_page()
和add_submenu_page()
自定义帖子类型的链接是page=edit.php?post_type=survey
对于菜单页面是admin.php?page=my_survey
我隐藏了,custom post type
因为我不想显示它,我只想有一个菜单,但有一个指向子菜单页面的链接custom post type
admin.php?page=
问题是当我在菜单中添加链接时,菜单中的所有链接都有前缀
menu_slug => 'edit.php?post_type=survey'
它补充说
admin.php?page=edit.php?post_type=survey
无论如何,我可以从一个子菜单中删除该前缀吗?
我正在开发 OOP 这就是我添加子菜单的方式
public function setSubPages()
{
$this->subpages = [
[
'parent_slug' => 'survey',
'page_title' => 'Survey Plugin',
'menu_title' => 'Survey',
'capability' => 'manage_options',
'menu_slug' => 'edit.php?post_type=survey',
'callback' => [$this->callbacks, 'adminDashboard'],
];
}
和我的自定义帖子类型
public function activate()
{
$labels = [
'name' => 'survey',
'singular_name' => 'survey',
];
$args = [
'labels' => $labels,
'public' => true,
'has_archive' => false,
'menu_icon' => 'dashicons-email-alt',
'supports' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_in_menu' => false
];
register_post_type( 'survey', $args );
}
如果我不够清楚,请告诉我谢谢