get $post (object,parts/values) in meta-box

Do not rely on globals like get_the_ID() or get_post() do. Use the parameters for your callbacks.

You get the current post object twice:

  1. When you register the metabox, you get the post object as a second parameter.
  2. When your output callback is called, you get it as the first parameter.

Here is an example showing both cases:

add_action( 'add_meta_boxes', function( $post_type, \WP_Post $post ) {
    add_meta_box(
        'test', // handle
        'Box title', // title
        function( \WP_Post $post ) { // output
            print get_the_title( $post );
    });
});