导入Instagram照片作为WordPress帖子


Import Instagram photos as WordPress posts

我正在使用这个插件,布局在这里:http://mlitzinger.com/articles/instagram-to-wordpress-posts/

我已经安装了Crontrol插件,但我只设法获得一个帖子导入一次。Instagram数据正在正确返回,所以我假设它与帖子插入有关。这是用于插入获取的Instagram帖子的数据:

$json_feed = file_get_contents($url, false, $args);
$json_feed = json_decode($json_feed);
foreach($json_feed->data as $post):
    if(!slug_exists($post->id)):
        $new_post = wp_insert_post(array(
            'post_content'  => '<a href="'. esc_url( $post->link ) .'" target="_blank"><img src="'. esc_url( $post->images->standard_resolution->url ) .'" alt="'. $post->caption->text .'" /></a>',
            'post_date'     => date("Y-m-d H:i:s", $post->created_time),
            'post_date_gmt' => date("Y-m-d H:i:s", $post->created_time),
            'post_status'   => 'publish',
            'post_title'    => $post->id,
            'post_name'     => $post->id,
            'post_category' => array(7)
        ), true);
    endif;
endforeach;
function slug_exists($post_name){
    global $wpdb;
    if($wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $post_name . "'", 'ARRAY_A')):
        return true;
    else:
        return false;
    endif;
}

而不是试图创建我自己的插件,将不得不维护每次Instagram更新,我决定只是去https://ifttt.com/,因为它包括Wordpress和Instagram。它监听一个Instagram帖子,然后用我定义的格式在Wordpress中插入一个帖子。