When you add a meta box, the post object is passed to the function that outputs your meta box content, and the ID is immediately available. Here’s a quick proof-of-concept that will put the ID in a field in a post meta box when creating a new post:
function wpd_sku_meta_box() {
add_meta_box(
'wpd_sku',
'SKU',
'wpd_render_meta_box',
'post'
);
}
add_action( 'add_meta_boxes', 'wpd_sku_meta_box' );
function wpd_render_meta_box( $post ) {
// $post->ID contains the ID of newly created post:
echo '<input type="text" id="wpd_sku" name="wpd_sku" value="' . $post->ID . '">';
}
function wpd_sku_save( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post_id;
if ( ! isset( $_POST['wpd_sku'] ) )
return $post_id;
$sku = $_POST['wpd_sku'];
update_post_meta( $post_id, '_wpd_sku', $sku );
}
add_action( 'save_post', 'wpd_sku_save' );
but please don’t use this code as-is, start with the example on the add_meta_box
codex page, which has some nonce and permission checks.