Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Populate editorial metadata fields when creating a new post
* A quick snippet to indicate how you might be able to populate Edit Flow editorial metadata fields when creating a new post
* Please keep in mind: I haven't tested this code, so it may need a bit of fixing before it actually works
* @see
// ... All of your form processing to prepare the data for wp_insert_post()
$post_id = wp_insert_post( $my_new_post_array );
// Save some of the form data as editorial metadata if Edit Flow is active and the module is enabled
global $edit_flow;
if ( $post_id && is_object( $edit_flow ) && $edit_flow->helpers->module_enabled( 'editorial-metadata' ) ) {
// Save an email address submitted in the form to an editorial metadata term with slug 'email-address'
// First we sanitize the data, then we get the term, then we get the term's postmeta key, and then
// we save the data to our newly created post
$email_address = sanitize_email( $_POST['form-email-address'] );
$email_address_term = $edit_flow->editorial_metadata->get_editorial_metadata_term_by( 'slug', 'email-address' );
$email_address_key = $edit_flow->editorial_metadata->get_postmeta_key( $email_address_term );
update_post_meta( $post_id, $email_address_key, $email_address );
// If you want to save data for more editorial metadata terms, you'd basically want to
// repeat the code for each form field
// ... do whatever else you need to do after saving your editorial metadata term data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.