Maybe I am going about this all wrong, but I have developed a plugin and want to add a menu item for my custom post type Candidates. The menu item shows up fine, but the link is wrong. The link being https://domain.com/wp-admin/admin.php?page=edit.php?post_type=candidates. Obviously, what I want is https://domain.com/wp-admin/edit.php?post_type=candidates. If I put edit.php?post_type=candidates in the parent_slug then the link is correct, but the Candidates menu item then shows up at the top of the menu and the first menu item ‘BDN Election Settings’ disappears. Any help is greatly appreciated.
if( function_exists('acf_add_options_page') ) {
$parent = acf_add_options_page(array(
'page_title' => 'BDN Election Settings',
'menu_title' => 'BDN Elections',
'menu_slug' => 'bdn-election-settings',
'capability' => 'edit_posts',
'icon_url' => 'dashicons-archive',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'General Settings',
'menu_title' => 'General Settings',
'menu_slug' => 'bpc-elections-general',
'parent_slug' => 'bdn-election-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Current Election Settings',
'menu_title' => 'Current Election',
'menu_slug' => 'current-election',
'parent_slug' => 'bdn-election-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Election Page Builder',
'menu_title' => 'Elections Builder',
'menu_slug' => 'elections-builder',
'parent_slug' => 'bdn-election-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Candidates',
'menu_title' => 'Candidates',
'menu_slug' => 'edit.php?post_type=candidates',
'capability' => 'edit_posts',
'parent_slug' => $parent['menu_slug'],
'redirect' => false,
));
}