Problem with adding exta field in metabox in custom post type

You didn’t retrieve your 2 values in the save_post action.

You need to get $_POST[’freebie-demo’] (it’s ok for it) and $_POST[‘freebie-downurl’]

If you want an array post meta value based, you can do something like that :

// Sanitize user input.
$de_url['name'] = sanitize_text_field( $_POST['freebie-demo'] );
$de_url['url'] = esc_url($_POST['freebie-downurl']);

// Update the meta field in the database.
update_post_meta( $post_id, '_demo_url', $de_url );

Hope it will help you !

Leave a Comment