Home > database >  add_meta_box showing blank screen in my page
add_meta_box showing blank screen in my page

Time:11-29

I am working on the plugin and getting issues in add_meta_box.

// Page URL- 

http://localhost:8080/wordpress/wp-admin/admin.php?page=testingpages&action=edit

//Plugin page code

if ($_GET['action'] == 'edit') {
        include('admin/views/view-edit.php');
}

The below is code, I am using on the view-edit.php page

function adding_custom_meta_boxes($post)
{
    add_meta_box(
        'testingpages',
        __('My Meta Box'),
        'render_my_meta_box',
        'page',
        'normal',
        'default'
    );
}
add_action('add_meta_boxes', 'adding_custom_meta_boxes');

function render_my_meta_box()
{
    // code here
}

i am getting blank screen. Any idea where is the issue/

Edited.

from add_action('add_meta_boxes_post', 'adding_custom_meta_boxes');

to add_action('add_meta_boxes', 'adding_custom_meta_boxes');

CodePudding user response:

You Can use this action and try this:

add_action('add_meta_boxes', 'adding_custom_meta_boxes');

CodePudding user response:

The meta box is available only for existing and custom post types, not admin pages.

There is a way to make it work on the options page. Create option page

Check out some examples: here

  • Related