Adding Custom Metaboxes to Custom Pages

The add_meta_boxes hooks load in edit-form-advanced.php. Your custom plugin page “test” does not use that file. You need to hook into the “plugin admin page hooks” instead.

Secondly, the third parameter of add_meta_box is just the CPT slug, not the page slug you have.

Here is what you need to change:

add_action("load-my-cpt_page_my-cpt-slug", "my_add_metaboxes");
function my_add_metaboxes()
{
    add_meta_box("my-cpt-metabox", "My CPT Metabox", "display_my_metabox", "my-cpt", "normal", "core");
}

Leave a Comment