Toolset:. Populate custom field with post title

function tssupp_set_pp_title ( $post_id, $post, $update ) {
  $field_slug = 'practice-point-title';
  $post_type_slug = 'practice-point';
    
  // - bail on wrong post type or on pre-publish auto draft title
  $post_type = get_post_type( $post_id );
  $post_title = get_the_title( $post_id );
  if ( ( $post_type !== $post_type_slug ) || ( $post_title == 'Auto Draft') )  {
    return;
  }
    
  update_post_meta( $post_id, 'wpcf-' . $field_slug, get_the_title( $post_id ) );
}
    
add_action( 'save_post', 'tssupp_set_pp_title', 100, 3);

Visto en https://toolset.com/forums/topic/populate-custom-field-with-post-title/

Toolset:. Populate custom field with post title Leer más »