wp_insert_post returns int(0) 时间:2017-01-13 作者:Mathis Hüttl 如果我运行以下代码,它会返回一个int(0)。Wordpress创建帖子,但帖子标题为空,尽管$name变量已填充。$postID = wp_insert_post(array( "post_title" => $name, "post_status" => "publish", "post_type" => "mycustomposttype", ), true); var_dump($postID); 1 个回复 SO网友:Tunji 根据法典上的注释wp_insert_post()post_title and post_content are required如果希望内容为空,可以编写wp_insert_post args数组因此:$postID = wp_insert_post(array( "post_title" => $name, "post_status" => "publish", "post_content => " ", "post_type" => "mycustomposttype", ), true); 文章导航