Beispiel #1
0
 public function import_custom_posts()
 {
     $posts_json = $this->TP_import_posts;
     $posts_array = json_decode($this->TP_import_posts, true);
     foreach ($posts_array as $post) {
         $newPost = new PunchPost();
         //Standards
         $newPost->set_title($post["post_title"]);
         $newPost->set_type("essential_grid");
         $newPost->set_content($post["post_content"]);
         $newPost->set_post_state("publish");
         //Categories
         $newPost->set_tax('essential_grid_category');
         $newPost->set_tax_terms($post['post_categories']);
         //Tags
         if (!empty($post['post_tags'])) {
             $newPost->set_post_tags($post['post_tags']);
         }
         //Meta
         $newPost->set_post_meta($post["post_options"]);
         $post_id = $newPost->create();
     }
 }