Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <? require_once('wp-config.php');
- /* for loop to get data */
- $string = file_get_contents("/home/zhou3594/multi/hwzhiyin.json");
- $json_str = json_decode($string, true);
- $i = 0;
- foreach($json_str as $row){
- ++$i;
- $urls = $row['urls'];
- $mp3 = implode(',', $urls['mp3']);
- $youtube = implode(',', $urls['youtube']);
- $images = implode(',', $urls['images']);
- $my_post = array(
- 'post_title' => wp_strip_all_tags($row['title'][0]),
- 'post_content' => $row['content'],
- 'post_date' => $row['pdate'],
- 'post_name' => $row['alias'][0],
- 'post_status' => 'publish',
- 'post_author' => 1,
- 'post_category' => array(2, 6),
- );
- $post_id = wp_insert_post($my_post);
- add_post_meta($post_id, 'created_by_alias', $row['poster'][0], true);
- add_post_meta($post_id, 'post_url', $row['post_url'][0], true);
- add_post_meta($post_id, 'mp3', $mp3, true);
- add_post_meta($post_id, 'youtube', $youtube, true);
- wp_set_post_terms($post_id, $tags_list);
- echo 'Record ' . $i . ' processed';
- echo "\r\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment