Some observations:
1) The hook save_post
takes 2 arguments:
add_action( 'save_post', 'save_postdata_dynamic_inventory_metabox', 10, 2 );
function save_postdata_dynamic_inventory_metabox( $post_id, $post_object ) { }
2) I don't think checking for permissions is necessary (at least, never seen it). Just in case, this is an example of the post_object
use:
if ( 'location_inventory' == $post_object->post_type )
3) Short this check:
if ( !isset($_POST['inventory_noncename']) || !wp_verify_nonce( $_POST['inventory_noncename'], 'inventory-nonce' ) )
return;
4) The use of the_ID()
inside the function save_postdata_dynamic_inventory_metabox
is wrong. This is only available inside a Loop and you already have $post_id
at hand.
5) Finally, and the most important, the way you're handling the $meta_key
is wrong. For one, it's not defined inside the function my_metabox_render
. Check this Answer for a working example.
Research in this search query to find more examples.