Closed champsupertramp closed 3 years ago
Hi,
Use the show_in_menu
custom post type argument. For an existing admin page root menu created with Admin Page Framework, pass the admin page class name as it serves as the menu slug.
I've uploaded example plugins.
Hi @michaeluno Thanks for your attention.
I tried the following code snippet but unfortunately, the submenu don't reigster. The post type is created and the root menu is there. It's just the submenu doesn't appear in the parent menu.
class APFDemo_CPTSubmenu_AdminPage extends AdminPageFramework {
public function setUp() {
$this->setRootMenuPage( 'CPT Demo - CPT Submenu','dashicons-welcome-widgets-menus', 100 );
$this->addSubMenuItems(
array(
'title' => 'Main',
'page_slug' => 'apf_demo_cpt_submenu_main',
'order' => 10,
)
);
}
/**
* @callback do_{page slug}
*/
public function do_apf_demo_cpt_submenu_main() {
echo "<p>Hello.</p>";
}
}
class APFDemo_CPTSubmenu_PostType_A extends AdminPageFramework_PostType {
public function setUp() {
$this->setArguments(
array(
'labels' => array(
'name' => 'CPT Submenu A',
'menu_name' => 'CPT Submenu A',
),
'show_ui' => true,
'show_in_menu' => 'APFDemo_CPTSubmenu_AdminPage',
'submenu_order_manage' => 20,
)
);
}
}
new APFDemo_CPTSubmenu_AdminPage;
new APFDemo_CPTSubmenu_PostType_A('cpt_newtest', null, __FILE__);
In your code, extendsAdminPageFramework {
will code an error. Try the examples shown on Gist linked in my previous reply. They can be downloaded as a zip file and run as a plugin. Install them on your test site with the Admin Page Framework - Loader plugin activated.
Hi @michaeluno
It's a typo with my example but it's already set as extends AdminPageFramework
in the plugin that i'm working on. I'm also able to create root pages, section and fields.
Regards,
Try the example plugins on a test site which only activates the Admin Page Framework - Loader plugin, NOT on your development plugin in order to eliminate any possible factors which cause problems.
The steps you need to take is:
And see what happens. If it doesn't give you a desired result, post screenshots.
Hi @michaeluno
Good news! I'm able to make it work now within the development plugin. It was an issue with my class calls.
I've changed it from 'show_in_menu' => 'Admin_Settings',
to 'show_in_menu' => '\The_Subscription\Admin_Settings',
Thank you very much for your guidance!
Regards,
Okay, great.
Type of issue
Prerequisites
dev
branch.Steps to reproduce the issue (for Bug report)
register_post type()
edit.php?post_type=mycpt
to the following Root Menu:And the result is: it is only show as a link and doesn't seem to highlight the submenu.
I tried using the
add_submenu_page
to register it with the root pagecnum_subscriptions
but it doesn't add the CPT submenu to the Root MenuDashboard
. What could be the right action hook so that it registers theadd_submenu_page
Here's the code for adding the submenu:
Thanks for this great open-source framework.