I am not a javascript master by any stretch of the imagination. “Hello World!” is as funky as I get.
I am looking to add an instagram feed on my website without plugins. Most of the plugins I’ve seen (smashballoon, etc.) add some bloat I’d like to avoid. Plus doing my own css stylings gives me more freedom.
You can skip the part with the token refresh for testing purposes, it will work for at least 60 days.
After you have generated your access token, copy the following code into a code element, paste your Access Token, and if everything works your images will appear like mine.
<div id="instafeed"></div>
<script type="text/javascript" src="https://unpkg.com/instafeed.js@2.0.0/dist/instafeed.js"></script>
<script type="text/javascript">
var feed = new Instafeed({
accessToken: 'your-access-token'
});
feed.run();
</script>
There are some options as well as custom templates available, but you need to write at least some HTML and CSS to style your “feed” accordingly.
So you don’t actually have to create a fb app to get the token? You can just use instant-tokens.com and then just paste the js code that Tim posted? I created an instant token and I added it on the code but instagram images don’t show up at all.
No. The instant-tokens page does it all for you. It has two options to pass that token on, the javascript and the json. I just copy/pasted the javascript url.
That’s because you’ll need to A. change the myawesomewordpresspage.com to your own page and upload the javascript there
OR
B. delete that line and uncomment the unpkg.com line.
I uploaded the javascript because Lighthouse kept moaning about external scripts and whatnot. Might not even be worth the effort since it is such a small script.
oh, got it! yes, I changed the url of the page but can you send me a link with the javascript code that I need to upload to wp-content/plugins/instafeed folder? I have some trouble locating the javascript code.
The B solution that you mentioned, you mean delete completely the line of code below? I don’t understand exactly what you mean by “uncomment”?
Yeah, success!! It worked now, you explained so clearly what I was doing wrong. Thank you so much, I can get rid of the smush feed instagram plugin and use this light code.
Is there a way to make the feed images show in random instead of chronological order? I clicked on the links with options and custom template but I couldn’t find that specific function. Also, when I check the page in google page speed, it says that Instagram images should have properly size images and serve them in next-gen formats. I already have a webp plugin for my other images on the website but it doesn’t serve insta images in webp also.
As for PSI complaining about next gen stuff, I wouldn’t worry about it since it is an external image that you have zero control over. You can try to import the images into your local server and resize/compress them there, but you’ll have to do that custom coding yourself and quite frankly, that’s just too much of a headache if I were you.
That I am not sure. Look at how Instagram passes arguments via their API and you should find some information there. The documentation for the instafeed is not very in depth.
is that code still working? ive pasted the code (have gotten insta token already and used that link). ive also hosted the instafeed.js or used the direct link to the github, nothing appears to be rendering.
wanted to make sure this method still works before trying more
Still works for me. I have the script uploaded into a folder on my staging site and am calling that from the code block, pretty much how it is posted initially.
Check your console to see if there are any errors and let us know.