Wordpress - "Quick Edit" > update clears out my custom meta values
I had the same issue. Just add the following code at the beginning of the save_post
action hook callback function (the function used to save the custom data).
// handle the case when the custom post is quick edited
// otherwise all custom meta fields are cleared out
if (wp_verify_nonce($_POST['_inline_edit'], 'inlineeditnonce'))
return;
What it actually does: it checks if the quick saving wp_nonce_field
exists and return
s if that's the case.
No need to create an additional hidden field in the form.
Add a hidden flag to the post edit form along with your custom fields. Something like
<input type="hidden" name="my_hidden_flag" value="true" />
Then, wrap all of your custom save_post stuff in a check for this flag. Then you don't have to check for the autosave constant any more either--if the flag doesn't exist, it's either a quick edit or an autosave.
function custom_add_save($postID){
// Only do this if our custom flag is present
if (isset($_POST['my_hidden_flag'])) {
// called after a post or page is saved
if($parent_id = wp_is_post_revision($postID)) {
$postID = $parent_id;
}
if ($_POST['scottb_customHeader']) {
update_custom_meta($postID, $_POST['scottb_customHeader'], '_scottb_customHeader');
} else {
update_custom_meta($postID, '', '_scottb_customHeader');
}
if ($_POST['scottb_customTitle']) {
update_custom_meta($postID, $_POST['scottb_customTitle'], '_scottb_customTitle');
} else {
update_custom_meta($postID, '', '_scottb_customTitle');
}
}
}