通过Json链接将数据插入WordPress中的博客

时间:2018-12-11 08:57:39

标签: mysql json database wordpress

我想设置cron以通过Json链接自动更新我的博客。 http://xyz/wp-json/custom/v1/all-posts

1 个答案:

答案 0 :(得分:0)

$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 );
相关问题