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 は、投稿タイトルと投稿コンテンツを含む文字列配列です。確認したところ、null 値や問題のあるものは含まれていません。では、wp_insert_post が「コンテンツ、タイトル、および抜粋が空です」というエラーを返すのはなぜですか? どうもありがとう!