WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

update_post_meta($post_id, 'custom_field_name', 'custom_field_value') updates a custom field in a post. How to do the same with a custom post type ?

share|improve this question
It really should be the same. Is it not working? Have any example code? A custom post is still just a post essentially, and carries values in the post_meta table, just like a regular post. – GhostToast Jan 23 '13 at 14:38
I realize this function works within the loop only, and the loop already "knows" the type of post involved obviously! – drake035 Jan 24 '13 at 7:43

I'd register a 'add_meta_box' to the cpt, the form element will define the custom_field_name and the save action would call update_post_meta.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.