Can’t seem to attach uploaded image to post and set it as thumbnail
You have a variable scope problem. $post_id = wp_insert_post($post_information); function upload_user_file( $file = array() ) { require_once( ABSPATH . ‘wp-admin/includes/admin.php’ ); $file_return = wp_handle_upload( $file, array(‘test_form’ => false ) ); // … You set $post_id outside of your upload_user_file() function but that means that it is unavailable inside the function where you need it for … Read more