I’m trying to use wp_insert_post to create a front-end submission form so visitors can create a post AND update the meta box fields of that post — not the custom fields.
For example, when I use the following in the submission form…
<?php update_post_meta($post_id, $meta_key, $meta_value); ?>
…it updates the built-in custom field section of the newly created post, but not the meta boxes that I created. Any ideas?
It’s all going into the same table, you’re possibly not using the correct key name to insert it. The only thing that differentiates custom field keys and keys used for metaboxes is that metabox keys are typically prefixed with an underscore to hide them from the list that shows up in the custom fields section. it’s also possible to store multiple things as an array under a single entry. that may be the case if you’re using a metabox helper class of some sort to generate the metaboxes. look directly in the table to see how your metabox data is being stored.
Here is some code that I’ve used to add posts from a front end form that also adds meta data and taxonomy terms. Note that snippet extracts all of the security, data validation and data sanitization. It just show what I do with the data to add it to the database once I’ve sanitized it all.