コードを使用していくつかの静的ページを WP Web サイトにインポートしていますが、解決策が見つからない 2 つの問題があります。
これが私の挿入コードです:
$data = getPost(1);
// details for the post we're about to insert
$my_post = array(
'post_title' => $data['page_title'],
'post_date' => date('Y-m-d H:i:s',strtotime($data['date'])),
'post_date_gmt' => date('Y-m-d H:i:s',strtotime($data['date'])),
'post_content' => '<p>' . $data['intro'] . '</p>' . $data['body'],
'post_status' => 'publish',
//'post_category' => (!empty($cats[$data['category']]) ? $cats[$data['category']] : 1),
'post_author' => (!empty($users[$data['author']]) ? $users[$data['author']] : 9),
'post_name' => $data['slug'],
'post_type' => 'post'
);
$data の中身が気になる場合は、次のとおりです。
Array ( [post_title] => Gutscheine bei Bingo3X gewinnen [post_date] => 2013-12-08 00:00:00 [post_date_gmt] => 2013-12-08 00:00:00 [post_content] => Nicht nur Geld gewinnen Macht Spaß, sondern Gutscheine können ebenfalls ihren Vorteil haben. So gibt es mit der Pouch-A-Vouch Aktion bei Bingo3X zurzeit Gutscheine im Wert von 30 £ gewinnen.
Nicht nur Geld gewinnen macht Spaß、sondern Gutscheine können ebenfalls ihren Vorteil haben. So gibt es mit der Pouch-A-Vouch Aktion bei Bingo3X zurzeit Gutscheine im Wert von 30 £ gewinnen.
[post_status] => 公開 [post_author] => 9 [post_name] => Gutscheine-bei-bingo3x-gewinnen [post_type] => post )
http://codex.wordpress.org/Function_Reference/wp_insert_postによると、「post_name」は投稿のスラッグ(リンク)を作成します。このデータをインポートすると、投稿が正しく追加されますが、奇妙な番号がmysite.com/2013/10/08/gutscheine-bei-bingo3x-gewinnen-5 <--- その -5 はどこからともなく来ています..何かアイデアはありますか? :)
もっと大きな問題。コード経由で Featured_image を追加するにはどうすればよいですか? URL を持っています (または、画像をローカルに配置できます。サイズはありますが、投稿に挿入する方法がわかりません。何らかの add_post_meta または wp_set_object_terms が役立ちますか? しかし、そこに何を書けばよいかわかりません。 ...
ありがとう!!