static function importData($data, $post_type) { $count = 0; foreach ($data as $dataObject) { $posts_array = QMModel::get_posts_by_title($dataObject, $post_type); //print_r($posts_array); $check = true; if (!is_null($posts_array)) { foreach ($posts_array as $p) { if ($p->post_status == 'publish') { $check = false; } } } if ($check) { $args = array('post_title' => $dataObject, 'post_status' => 'publish', 'post_content' => $dataObject, 'post_author' => 1, 'post_type' => $post_type); $pid = wp_insert_post($args); $count++; } } }