通过添加post_type
到add_submenu_page
菜单slug它将激活CPT页面菜单。然后,您必须使用以下命令将父页面作为该CPT添加到该commnet页面submenu_file
滤器
# Move comment to CPT
function wpse354847_relocate_comments_in_admin_menu()
{
// Remove existing parent menu.
remove_menu_page( \'edit-comments.php\' );
// Move Comments under Complaints (\'complaint\').
add_submenu_page(
\'edit.php?post_type=complaint\', //$parent_slug
__( \'Replies\', \'wpse354847\' ), //$page_title
__( \'Replies\', \'wpse354847\' ), //$menu_title
\'edit_posts\', //$capability
\'edit-comments.php?post_type=complaint\' //$menu_slug
);
}
add_action( \'admin_menu\', \'wpse354847_relocate_comments_in_admin_menu\' );
# add active page for parent page
add_filter(\'submenu_file\', \'menuBold\');
function menuBold($submenu_file)
{
global $pagenow;
if (( $pagenow == \'edit-comments.php\' ) && ($_GET[\'post_type\'] == \'complaint\')) { // The address of the link to be highlighted
return \'edit-comments.php?post_type=complaint\';
}
// Don\'t change anything
return $submenu_file;
}