media_sideload_image generates blank?
-
I’m creating a custom post form that is supposed to take an external image and uploads it to the media library and attach it to that post. This should be possible by using media_sideload_image, but I’m getting a blank page instead of working correctly, no error either. My code:
// Add the content of the form to $post as an array $new_post = array( 'post_title' => $title, 'post_content' => $description, 'tags_input' => $tags, 'post_type' => 'link_submit', 'post_status' => 'publish' ); //save the new post and return its ID if ($stop == false){ $pid = wp_insert_post($new_post); update_post_meta($pid,'Link',$link,true); update_post_meta($pid,'Type',$type,true); // attach image set_time_limit(300); $upload = media_sideload_image($link, $pid, "test"); if ( is_wp_error( $upload ) ){ die( 'Nope' ); } $link = get_permalink( $pid ); wp_redirect( $link."?posted" ); die(); }
Ideas?
Thanks, Dennis
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘media_sideload_image generates blank?’ is closed to new replies.