I am attempting to generate posts primarily based on a JSON doc. I am caught on the attempting to assign the ID from the json doc to the submit’s wordpress ID. I learn on right here that the way in which of going about that is although setting an ‘import_id’ on wp_insert_post
$json = json_decode("{
"tt1412213":{
"title":"Movie",
"rating":"excellent"
}
}", true);
foreach($json as $merchandise) {
$itemID = array_keys($json, $merchandise);
if (get_post_status( $itemID ) == false ) {
if($merchandise["title"] and $merchandise["rating"]){
international $user_ID;
wp_insert_post(array(
'post_title' => $merchandise["title"],
'post_content' => $merchandise["rating"],
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'submit',
'post_category' => array(0),
'import_id' => $itemID
));
}
}
}
I would love my submit to have the ID tt1412213
however it defaults to a quantity as a substitute. Something I am lacking?