custom post types – Save Multiple Metabox values

Question

How to Save Multiple Metabox values ?

I have 3 fields like below image.

enter image description here

Should I use below code ?

if (isset($_POST['name'])) {
    update_post_meta($post_id, 'name', sanitize_text_field($_POST['name']));
}

if (isset($_POST['address'])) {
    update_post_meta($post_id, 'address', sanitize_text_field($_POST['address']));
}

if (isset($_POST['phone'])) {
    update_post_meta($post_id, 'phone', sanitize_text_field($_POST['phone']));
}

Is there any way to Save multiple metabox values ?

0
Foysal 5 months 2022-07-01T21:05:07-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse