【问题标题】:Import Instagram photos as WordPress posts将 Instagram 照片导入为 WordPress 帖子
【发布时间】:2017-04-16 17:17:02
【问题描述】:

我正在使用这个插件,在这里列出: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;
}

【问题讨论】:

    标签: php wordpress instagram


    【解决方案1】:

    我没有尝试创建每次 Instagram 更新时都必须维护的自己的插件,而是决定使用 https://ifttt.com/,因为它同时包含 Wordpress 和 Instagram。它会侦听 Instagram 帖子,然后使用我定义的格式在 Wordpress 中插入帖子。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 2021-02-06
      相关资源
      最近更新 更多