Add custom meta box on Post page

You need to use the add_meta_box function

add_action( 'add_meta_boxes', 'my_custom_meta_box' ) );
function my_custom_meta_box(){

  $args = array();

  add_meta_box(
    'my_metabox_id',
    __( 'My Meta Box', 'my_textdomain' ), // Title
    'my_callback_function',               // Callback function that renders the content of the meta box
    'post',                               // Admin page (or post type) to show the meta box on
    'side',                               // Context where the box is shown on the page
    'high',                               // Priority within that context
    $args                                 // Arguments to pass the callback function, if any
  );
}


function my_callback_function( $args ){

  //The markup for your meta box goes here

}

Leave a Comment