0

I'm looking for a way how I can import an Instagram post to a Wordpress post.

So to make it clear: I'm NOT looking for a Instagram Feed plugin. I need to import an Instagram post to a Wordpress blog posts separately.

This is because I need a post loop with multiple categories where one of them is an Instagram post.

So how can I do that? If there is a plugin for this, that will be fine. All suggestions are welcome. I prefer the most simple solution obviously.

Thanks in advance.

  • You need anyway to create an Instagram application for that and build a small API interface. – huraji Sep 30 '19 at 11:29
2

I'm not currently aware of other ways rather then:

  • Creating an Instagram App
  • Get an access token
  • Build a small API handler

Something like this to put in your functions.php:

function my_instagram()
{
    $transient_key = 'instagram_data';
    $feed_data = get_transient( $transient_key );
    if( false === $feed_data ) {
        $feed_data = json_decode(file_get_contents('https://api.instagram.com/v1/users/self/media/recent/?access_token=<ACCESS_TOKEN>&count=4'));
        if ( is_array( $feed_data->data ) ) {
            set_transient( $transient_key, $feed_data->data, 60*60*24 );
        }
    }
    return $feed_data;
}

Later of course you can manipulate your $feed_data as you need. Adjust the transient according to your requirements.

It's called feed because it is what it is. I'm afraid though they lately restricted the endpoints. Read more https://www.instagram.com/developer/endpoints/.

You can generate intagram access tokens here https://instagram.pixelunion.net/.

  • Thank you for your answer, is there a tutorial for this? – Thomas Tromp Oct 1 '19 at 11:29
  • I think the best place to start would be developers.facebook.com/docs/instagram then the function in the example works out of the box. You can call it anywhere in your theme like my_instagram() and it will output the feed data. – huraji Oct 1 '19 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.