Skip to content

Instantly share code, notes, and snippets.

@marktenney
Last active September 24, 2020 18:59
Show Gist options
  • Save marktenney/8e412b6629ec41910859f8cd758b45db to your computer and use it in GitHub Desktop.
Save marktenney/8e412b6629ec41910859f8cd758b45db to your computer and use it in GitHub Desktop.
generate-post-title-from-custom-fields.php
<?php
function update_post( $post_id ) {
$firstname = rwmb_meta('person_firstname');
$lastname = rwmb_meta('person_lastname');
$post = array(
'ID' => $post_id,
'post_title' => $firstname . ' ' . $lastname,
'post_name' => $post_id,
);
wp_update_post( $post );
}
add_action('save_post_people', 'update_post', 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment