Support

Account

Home Forums ACF PRO Use acf field to create post title Reply To: Use acf field to create post title

  • I’ve been using this…give it a try

    //Auto add and update Title field:
      function my_post_title_updater( $post_id ) {
    
        $my_post = array();
        $my_post['ID'] = $post_id;
    
    // custom post type
        $foo           = get_field('foo');
    
        if ( get_post_type() == 'foo' ) {
          $my_post['post_title'] = get_field('acf_title_slug');
        } 
    
        // Update the post into the database
        wp_update_post( $my_post );
    
      }
       
      // run after ACF saves the $_POST['fields'] data
      add_action('acf/save_post', 'my_post_title_updater', 20);
    //END Auto add and update Title field: