I want to save multiple custom fields for a custom post in one go. Something like get_post_custom() except for that I need to set it this time.
Leave a Reply
You must be logged in to post a comment.
I want to save multiple custom fields for a custom post in one go. Something like get_post_custom() except for that I need to set it this time.
You must be logged in to post a comment.
Custom post meta data are generally updated in the database via a callback function hooked into
save_post
. (Others:draft_post
,publish_post
,future_post
.)The custom post meta data are part of the
$_POST
data sent on-submit for the edit post screen, so simply look for them there, sanitize them, and then update them in the database.I’m omitting things like nonce-checking and sanitizing
$_POST
data. You’ll want to incorporate them into your callback as necessary.For example: