Support

Account

Home Forums General Issues Change the title of a custom post type to match filed value? Reply To: Change the title of a custom post type to match filed value?

  • 
    add_action('acf/save_post', 'acf_field_to_title', 20);
    function acf_field_to_title($post_id) {
      remove_filter('acf/save_post', 'acf_field_to_title', 20);
      $title = get_field('your-field', $post_id);
      if ($title) {
        $post = get_post($post_id);
        $post->post-title = $title;
        wp_update_post($post);
      }
      add_action('acf/save_post', 'acf_field_to_title', 20);
    }