I want to be able to add a metabox to a new submenu page that I have created. I have the following basic code which I was hoping would work but it seems not to:
add_action("init", "my_register_post_types");
function my_register_post_types()
{
register_post_type("my-cpt", array(
"label" => "My CPT",
"public" => true
));
}
add_action("admin_menu", "my_add_menu_items");
function my_add_menu_items()
{
add_submenu_page("edit.php?post_type=my-cpt", "Test Page", "Test Page", "edit_posts", "my-cpt-slug", "display_my_test_page");
//return value from this is my-cpt_page_my-cpt-slug
}
function display_my_test_page()
{
do_meta_boxes("my-cpt", "normal", null);
}
add_action("add_meta_boxes", "my_add_metaboxes");
function my_add_metaboxes()
{
add_meta_box("my-cpt-metabox", "My CPT Metabox", "display_my_metabox", "my-cpt_page_my-cpt-slug", "normal", "core");
}
function display_my_metabox()
{
echo "Hello";
}
According to http://shibashake.com/wordpress-theme/standard-wordpress-metabox, I should be using the return value of add_submenu_page to be used in the add_meta_box function in place of a CPT slug.
I was hoping that the the metabox would appear on the new "Test Page" but no joy. Any ideas? Am I missing something?