Support

Account

Home Forums Front-end Issues How do you create post_title from another field(s) in ACF Pro? Reply To: How do you create post_title from another field(s) in ACF Pro?

  • This is currently working on a custom post type for me.

    /**
     * Front end creation of new download
     * @author  Mike Hemberger
     * @link http://thestizmedia.com
     * @uses Advanced Custom Fields Pro
     */
    add_filter('acf/pre_save_post' , 'jivedig_newdownload_pre_save_post' );
    function jivedig_newdownload_pre_save_post( $post_id ) {
    
    	// check if this is to be a new post
        if( $post_id != 'new' ) {
            return $post_id;
        }
    
        // Create a new post
        $post = array(
    		'post_status' => 'publish',
    		'post_title'  => $_POST['acf']['field_5483b32a04842'], // beat_title
    		'post_type'   => 'download',
        );
    
        // insert the post
        $post_id = wp_insert_post( $post );
    
    	// update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
    
        // return the new ID
        return $post_id;
    
    }