Can’t set Post ID properly


I’m trying to generate posts based on a JSON document. I’m stuck at the trying to assign the ID from the json document to the post’s wordpress ID. I read on here that the way of going about this is though setting an ‘import_id’ on wp_insert_post

$json = json_decode("{
    }", true);

foreach($json as $item) { 
    $itemID = array_keys($filmJson, $item);
    if (get_post_status( $itemID ) == false ) {
        if($item["title"] and $item["rating"]){
            global $user_ID;
                'post_title' => $item["title"],
                'post_content' => $item["rating"],
                'post_status' => 'publish',
                'post_date' => date('Y-m-d H:i:s'),
                'post_author' => $user_ID,
                'post_type' => 'post',
                'post_category' => array(0),
                'import_id' => $itemID

I would like my post to have the ID tt1412213 but it defaults to a number instead. Anything I’m missing?

Fluxian 11 months 2021-09-09T09:52:50-05:00 0 Answers 0 views 0

Leave an answer