wp_insert_post appears to work, but no post on site
-
hi all,
i am hoping i am just missing something easy.
i have a script that inserts posts. i get no errors when the script runs, and all the posts end up in the wp_posts table (and the meta is in wp_postmeta), but if i try to edit any of those posts in admin, i get this error:
“You attempted to edit an item that doesn’t exist. Perhaps it was deleted?”i get a 404 if i try to view the post.
here is a code snippet:
$post = array(
‘post_author’ => 1,
‘post_title’ => $title,
‘post_name’ => $slug,
‘post_content’ => $content,
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘post_category’ => array(1487),
‘tags_input’ => $tags,
);
$keywords = $tags;
$metatitle = $title;
$metadescription = strip_tags($content);$newid = wp_insert_post($post);
if ($newid > 0)
{
add_post_meta($newid, ‘title’, $metatitle);
add_post_meta($newid, ‘description’, $metadescription);
add_post_meta($newid, ‘keywords’, $keywords);
}any help, or pointers on where i can look next, would be greatly appreciated. thanks much in advance!
- The topic ‘wp_insert_post appears to work, but no post on site’ is closed to new replies.