My meta box won’t save data. It’s a select form field and when I select and update the post, there’s nothing selected on refresh.
So here it is on PasteBin.
http://pastebin.com/tfrgasQC
Can anyone tell why my code won’t get wordpress to save the post with the data?
Thanks
1 Answer 1
If that is all of your code, you’re missing a save_post action to save the data. Refer to the code sample provided on add_meta_box.
add_action( 'save_post', 'save_my_meta_box_data' );
function save_my_meta_box_data( $post_id ){
// make sure it's not an autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
// verify your nonce
if ( !wp_verify_nonce( $_POST['my_noncename'], 'my-nonce' ) )
return;
// check post type, permissions
// validate your $_POST data
// update_post_meta();
}