我有以下php代码放在我的wordpress网站下。 我收到返回0并出现以下错误消息:
无法将帖子插入数据库
我的PHP代码是:
include('/home/xxx/httpdocs/wp-blog-header.php');
$my_wp_post = array();
$my_wp_post['post_title'] = 'it is title';
$my_wp_post['post_content'] = 'it is content';
$my_wp_post['post_status'] = 'publish';
$my_wp_post['post_author'] = 1;
$my_wp_post['ping_status'] = 1;
$my_wp_post['post_category'] = array('0');
#var_dump($my_wp_post);
$post_id = wp_insert_post( $my_wp_post, true );
if (is_wp_error($post_id))
{
$errors = $post_id->get_error_messages();
foreach ($errors as $error) {
echo "- " . $error . "<br />";
}
}
我在哪里弄错了?
答案 0 :(得分:1)