› Forums › NextScripts API Forums – Google+, Pinterest, LinkedIn, etc.. › Using wp_insert_post, Featured Image not posted › Reply To: Using wp_insert_post, Featured Image not posted
Just realized I post in wrong forum.
Anyway, I managed to make it work by delaying my post by 30 seconds.
//Since we have issue with Next Scripts: Social Networks Auto Poster and our featured image
//Delay the post for 30 seconds to make the plugin see the featured post
$post_date_delayed = current_time('timestamp') + 30;
// ADD THE FORM INPUT TO $new_post ARRAY
$new_post = array(
'post_title' => wp_strip_all_tags($title),
'post_content' => $comment,
'post_category' => $cat, // Usable for custom taxonomies too
'tags_input' => $tags,
'post_status' => 'future', // Choose: publish, pending, future, draft, etc.
'post_type' => 'post', //'post',page' or use a custom post type if you want to
'post_date' => date('Y-m-d H:i:s', $post_date_delayed),
);
//SAVE THE POST
$pid = wp_insert_post($new_post);
Just in case someone have similar problem like me