Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
2  
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

1 Answer 1

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

 
discard

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.