Now I am building a wordpress plugin. I need to add a metabox to the admin submenu page. I tried like this below,

add_action( 'add_meta_boxes', 'add_meta_boxs');
function add_meta_boxs()
    add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'meta_box', 'myContactForm', 'normal', 'high' );

I created a submenu page:

add_submenu_page( 'myForm',  'Add New' , 'Add New', 'manage_options', 'newForm', 'newform_page');

function newform_page()
       <div class="form-container-2">
        <?php do_meta_boxes('myContactForm', 'normal', null); ?>

Here "myContactForm" is a custom post type. Meta box was created in custom post type but what I need is meta box will be created within submenu page.

Anyone help me please.


Meta box are designed to work with Post(s) and Custom post types.

However you can make it work on options page if you know what you are doing.

Click here for sample code

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.