admin管理员组

文章数量:1122832

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); ?>
        </div>
    }

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.

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); ?>
        </div>
    }

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.

Share Improve this question edited Apr 18, 2017 at 10:35 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Apr 10, 2017 at 10:23 PreethiPreethi 137 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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

本文标签: Adding metabox to wordpress plugins menu page