【发布时间】:2013-09-12 19:10:37
【问题描述】:
我正在尝试通过 PHP 将 WooCommerce 产品插入 WordPress 数据库。 WooCommerce 产品只是 post-type=product 的帖子,所以我认为这应该可行:
$mypost = array('post-title' => $secondexplosion[0], 'post-type' => 'product',
'post-status' => 'publish', 'post-content' => $secondexplosion[1],
'post-excerpt' => '');
$postid = wp_insert_post($mypost, true);
$secondexplosion 是一个包含帖子标题和帖子内容的字符串数组;我检查了一下,它不包含空值或任何有问题的东西。那么,为什么 wp_insert_post 返回错误“内容、标题和摘录为空”?非常感谢!
【问题讨论】:
-
您应该使用下划线而不是破折号(即
post_content而不是post-content)。如果你改变这些应该可以工作
标签: php wordpress woocommerce