skip to Main Content

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');

2

Answers


  1. You Can use this action and try this:

    add_action('add_meta_boxes', 'adding_custom_meta_boxes');
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search