Let’s say your post type is named product
. You register your metabox with …
add_action( 'add_meta_boxes_product', 'register_product_metabox' );
function register_product_metabox()
{
// register the metabox
}
You get the post id in your callback per post object now:
function metabox_callback( $post )
{
$field = get_post_meta( $post->ID );
}
This happens because WordPress calls the callback with:
call_user_func($box['callback'], $object, $box);
See wp-admin/includes/template.php
.