• hi!

    i have a short plugin that downloads images and some information in one of my websites and creates a post out of the images and information taken, i’ve used the following codes to do it:

    $newfile = “someurl”;
    $file = wp_remote_fopen(url);
    wp_upload_bits($newfile, null, $file);

    if i place

    $postarr = array(
    ‘user_id’ => $user_ID,
    .
    .
    ‘fieldn’ => valueN
    );

    $id = wp_insert_post($postarr);

    before the code with wp_upload_bits(), the post is created

    but if i place it after the wp_upload_bits() code,

    the wp_insert_post() fails

    what seems to be the problem? Thanks in advanced.!

  • The topic ‘wp_insert_post not working when placing after wp_upload_bits’ is closed to new replies.