REQ Plugin Instagram to Wordpress

iluhin

Member
May 5, 2022
50
13
8
Hi, everyone!

Pls help me! I cant find in global internet this plugin. I want import my posts from Instagram to wordpress. Not embed i meen. 1:1 1 instagram post = 1 wordpress blog post.

i have over 6000 posts
 

nesym

Well-known member
Babiato Lover
Trusted Seller
Trusted Uploader
Sep 8, 2019
431
271
63
I personally don't know if such plugin exists. But here's an idea:

Why don't you try to use some language model out there and write a simple import script. You can also look into custom post types with custom fields in Wordpress. May be create a plugin that populates those fields with scraped data. For scraping you can look at Python libraries and may be add a cronjob.
 
  • Like
Reactions: m1ngo

m1ngo

Member
Feb 9, 2020
73
37
18
Hi, everyone!

Pls help me! I cant find in global internet this plugin. I want import my posts from Instagram to wordpress. Not embed i meen. 1:1 1 instagram post = 1 wordpress blog post.

i have over 6000 posts

I am providing you your start point, because you need create custom plugin for this functionality.

Code:
<?php
/**
 * Plugin Name: IG to WP
 * Description: A plugin to import Instagram posts to WordPress
 * Version: 1.0
 * Author: Your Name
 */

// Instagram API endpoint
define('INSTAGRAM_ENDPOINT', 'https://graph.instagram.com/me/media?fields=id,caption,media_type,media_url,thumbnail_url,permalink&access_token=');

// Your Instagram Access Token goes here
define('INSTAGRAM_ACCESS_TOKEN', 'your-access-token-here');

// Fetch Instagram Posts
function fetch_instagram_posts() {
    $url = INSTAGRAM_ENDPOINT . INSTAGRAM_ACCESS_TOKEN;
    $response = wp_remote_get($url);
    $body = wp_remote_retrieve_body($response);

    if (!is_wp_error($body)) {
        return json_decode($body, true);
    }

    return null;
}

// Convert Instagram Post to WordPress Post
function instagram_to_wordpress_post($instagram_posts) {
    if (!empty($instagram_posts)) {
        foreach ($instagram_posts['data'] as $post) {
            $post_exists = get_page_by_title($post['id'], OBJECT, 'post');

            // Skip if post already exists
            if ($post_exists) {
                continue;
            }

            $post_data = [
                'post_title' => $post['id'],
                'post_content' => $post['caption'],
                'post_status' => 'publish',
                'post_type' => 'post',
            ];

            // Insert the post into WordPress
            $post_id = wp_insert_post($post_data);

            // Add Featured Image
            if ($post['media_type'] === 'IMAGE') {
                // Download and attach image here
            }
        }
    }
}

// Execution logic
function execute_import() {
    $instagram_posts = fetch_instagram_posts();
    instagram_to_wordpress_post($instagram_posts);
}

// Schedule the event
if (!wp_next_scheduled('execute_import')) {
    wp_schedule_event(time(), 'hourly', 'execute_import');
}

add_action('execute_import', 'execute_import');

If you can't make it yourself, contact me and discuss details.
 
  • Like
Reactions: iluhin

iluhin

Member
May 5, 2022
50
13
8
I am providing you your start point, because you need create custom plugin for this functionality.

Code:
<?php
/**
 * Plugin Name: IG to WP
 * Description: A plugin to import Instagram posts to WordPress
 * Version: 1.0
 * Author: Your Name
 */

// Instagram API endpoint
define('INSTAGRAM_ENDPOINT', 'https://graph.instagram.com/me/media?fields=id,caption,media_type,media_url,thumbnail_url,permalink&access_token=');

// Your Instagram Access Token goes here
define('INSTAGRAM_ACCESS_TOKEN', 'your-access-token-here');

// Fetch Instagram Posts
function fetch_instagram_posts() {
    $url = INSTAGRAM_ENDPOINT . INSTAGRAM_ACCESS_TOKEN;
    $response = wp_remote_get($url);
    $body = wp_remote_retrieve_body($response);

    if (!is_wp_error($body)) {
        return json_decode($body, true);
    }

    return null;
}

// Convert Instagram Post to WordPress Post
function instagram_to_wordpress_post($instagram_posts) {
    if (!empty($instagram_posts)) {
        foreach ($instagram_posts['data'] as $post) {
            $post_exists = get_page_by_title($post['id'], OBJECT, 'post');

            // Skip if post already exists
            if ($post_exists) {
                continue;
            }

            $post_data = [
                'post_title' => $post['id'],
                'post_content' => $post['caption'],
                'post_status' => 'publish',
                'post_type' => 'post',
            ];

            // Insert the post into WordPress
            $post_id = wp_insert_post($post_data);

            // Add Featured Image
            if ($post['media_type'] === 'IMAGE') {
                // Download and attach image here
            }
        }
    }
}

// Execution logic
function execute_import() {
    $instagram_posts = fetch_instagram_posts();
    instagram_to_wordpress_post($instagram_posts);
}

// Schedule the event
if (!wp_next_scheduled('execute_import')) {
    wp_schedule_event(time(), 'hourly', 'execute_import');
}

add_action('execute_import', 'execute_import');

If you can't make it yourself, contact me and discuss details.
yes i wrote u! thx!!! i need this!!!
 

iluhin

Member
May 5, 2022
50
13
8
I personally don't know if such plugin exists. But here's an idea:

Why don't you try to use some language model out there and write a simple import script. You can also look into custom post types with custom fields in Wordpress. May be create a plugin that populates those fields with scraped data. For scraping you can look at Python libraries and may be add a cronjob.
if u know how release this, pls help me
 

Forum statistics

Threads
73,845
Messages
1,032,824
Members
232,128
Latest member
Adel Galal