Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've had a read of the existing posts on here and still can't see why my instance is doing this, but I'm using wp_insert_post to add a post with some data it's given, and it's inserting the post just fine but the function is returning 0 in place of the post ID - does it have to be triggered to use this?

    $ember_prepare_post = array(
    'post_author' => $ember_current_user_id,
    'post_category' => $ember_post_category,
    'post_content' => $ember_post_content,
    'post_title' => $ember_post_title,
    'post_status' => 'publish',
    'post_excerpt' => $ember_post_excerpt,
    'tags_input' => $ember_post_tags
    );

// now we've prepared an array with the data, we're going to save it into the WP database and obtain the resulting post ID.

$ember_newpost_id = wp_insert_post($ember_prepare_post, true);

I'm not seeing any errors, and have had a read of the wp_insert_post function itself and cannot see why it wouldn't work. The ID's of the posts it creates definitely aren't zero, either.

Thanks!

share|improve this question

closed as too localized by toscho Jul 6 '12 at 20:18

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Are you passing this "$ember_post_category" as an array? It should be. –  Banago Jul 29 '11 at 7:19
    
I'm having a similar problem - wish this weren't closed back in the day. Ours is giving errors (a warning, technically) when we try to create a new post in the admin interface. The warning can be traced back to this issue - I'm thinking it's a problem in our database somewhere... The warning message is: Warning: Creating default object from empty value in /home/xxx/public_html/wp-admin/includes/post.php on line 475 –  rinogo Dec 3 at 19:44
    
FYI, the solution to our particular problem was: eddiemoya.com/plugins/incorrect-datetime-bug-fix-wordpress –  rinogo Dec 3 at 20:03

Browse other questions tagged or ask your own question.