wp_insert_post() getting slower the more posts
I found the solution by the comment from birgire what tells to use wp_defer_term_counting() as follows: if( ! $errors ) { // Set wp_defer_comment_counting(); wp_defer_term_counting( true ); foreach( $lines as $line ) { // Import post $args = array( ‘post_title’ => $new_vipost_title, ‘post_content’ => $new_vipost_content, ‘post_status’ => ‘publish’, ‘post_type’ => $vipost_type, ); $post_id = wp_insert_post( … Read more