$slices = json_decode(file_get_contents('http://27.109.19.234/decoraidnew/wp-json/custom/v1/all-posts'),true); if ($slices) { foreach ($slices as $slice) {
$title = $slice[1];
} } $my_post = array(
'post_title' => $title,
'post_content' => 'This is my content',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(8,39) ); $post_id = wp_insert_post( $my_post, $wp_error );