I had a custom post type that only used custom fields, so I needed to generate a post title from there.
Here’s one way. You can if course chain as many if else as you want to check other types.
functions.php
function custom_post_type_title($post_id) { global $wpdb; if (get_post_type($post_id) == 'staff') { $name = get_post_custom_values('name'); $title = $name[0]; $where = array('ID' => $post_id); $wpdb->update($wpdb->posts, array('post_title' => $title), $where); } } add_action('save_post', 'custom_post_type_title');