I am trying to insert data into wp_post and wp_postmeta tables but it seems like i am doing something wrong.
Here is my code:
$post_data = array(
'post_title' => $data[0],
'post_content' => $data[1],
'post_status' => 'publish',
'post_type' => 'product'
);
$id = wp_insert_post($post_data);
add_post_meta($id, '_stock', $data[6]);
add_post_meta($id, '_price', $data[7]);
The post is inserted as it should but when i check the postmeta table no values had been inserted. I also tried the update_post_meta but still doesn't work.
Any suggestions?