How to get the `comment_post_ID`?
Do you actually insert the comments right after you created the CPT post? I.e. Both the snippets in the question are in the same scope, e.g. wp_insert_post( $post_array ); for($j = 1; $j <= $total; $j++){ … wp_insert_comment($comment_array); … }. If yes, then you can store the post ID returned by wp_insert_post() to a variable … Read more