Instagram Feeds 6.5 integrates with WPCode, so your custom JavaScript and CSS are managed there instead of in the plugin.
Would you like to manage your Instagram feed customizations with WPCode instead of the plugin’s own code boxes?
This guide covers how the WPCode integration works and how to use it with your feeds.
Before you get started, make sure Instagram Feed Pro is installed and activated on your WordPress site.
- How Does the WPCode Integration Work?
- Browsing the Snippet Library
- Moving Your Old Custom CSS and JS to WPCode
- Using Custom JavaScript and CSS
- Vertically Centering the Caption on Hover
- Frequently Asked Questions
How Does the WPCode Integration Work?
As of version 6.5, Instagram Feed Pro works directly with WPCode, a separate plugin that stores your custom code as snippets. That makes your customizations easier to manage and update.
The integration does two things. It adds a Snippets tab to the plugin’s settings with ready-made snippets from Smash Balloon. It also moves any code you saved in the old Custom CSS and Custom JS boxes into WPCode with one click.
Next, we’ll look at the Snippets tab.
Browsing the Snippet Library
To get started, we’ll open the Snippets tab in the plugin settings.
The Snippets tab lists the Smash Balloon snippets in the WPCode library that are tagged for Instagram Feed. You can use a snippet as it is or change it to fit your site.
- From your WordPress admin sidebar, go to Instagram Feed » Settings and click the Snippets tab.
- If WPCode isn’t installed yet, the tab asks you to install it. To do this, click One-click Install WPCode. If WPCode is installed but not active, click Activate WPCode instead. The page then reloads on the Snippets tab.
- Now each snippet shows as a card with a title. Next, click Use Snippet on a card to open that snippet in WPCode in a new tab.
For a snippet you’ve already added, the card button reads Edit Snippet instead. While WPCode isn’t installed or active, the tab also shows a Learn More button that opens this guide in a new tab.
Next, we’ll see how to move your older custom code into WPCode.
Moving Your Old Custom CSS and JS to WPCode
In Instagram Feed Pro, the Custom CSS and Custom JS boxes are deprecated, and WPCode replaces them. The two boxes only show on the Feeds tab when at least one of them already has code saved. If both are empty, they stay hidden and you add new code in WPCode.
When the boxes show, a DEPRECATED notice sits above them with a migration button. The migration moves your code into WPCode for you.
- From your WordPress admin sidebar, go to Instagram Feed » Settings and click the Feeds tab.
- In the notice, click the migration button. It reads One-click Install and Migrate if WPCode isn’t installed, One-click Activate and Migrate if it’s installed but not active, or One-click Migrate if it’s active.
- When it finishes, the page opens WPCode in your WordPress admin.
The migration creates one WPCode snippet for each box that had code, and turns each one on.
- The Custom CSS becomes a CSS snippet named Instagram Feed Custom CSS, placed in the site-wide header.
- The Custom JS becomes a JavaScript snippet named Instagram Feed Custom JS, placed in the site-wide footer. Your code is wrapped in a function named
sbi_custom_js, which is the name the plugin looks for.
After the snippets are created, the plugin empties the Custom CSS and Custom JS boxes.
Next, we’ll look at how custom CSS and JavaScript run on your feed.
Using Custom JavaScript and CSS
You can use WPCode to add your own CSS and JavaScript to your Instagram feeds. The sections below explain when each kind of code runs, so you can place it correctly.
Custom CSS
CSS saved in the Custom CSS box is added to the header of the page. If you add CSS in WPCode, place the snippet in the site-wide header, as the migration does.
Custom JavaScript
The Custom JS box supports regular JavaScript as well as jQuery. It runs after the feed finishes loading on the page. It runs again after you click the Load More button and the new posts are added to the feed.
The plugin does this by calling a function named sbi_custom_js, about a tenth of a second after each load. To get the same behavior from a WPCode JavaScript snippet in the site-wide footer, define the function like this.
var sbi_custom_js = function() {
// add code here
};
The Custom JS box also sets $ as a shortcut for jQuery. The function above doesn’t, and neither does a snippet the migration created. If your code uses $, add var $ = jQuery; as the first line inside the function.
Customizing the Lightbox
Instagram Feed Pro looks for a JavaScript function named sbiLightboxAction and runs it a tenth of a second after the lightbox builds a post. You can use it to customize the lightbox. To add your own code, add a WPCode JavaScript snippet that defines it with this syntax.
window.sbiLightboxAction = function() {
// add code here
};
Reels and Swipe View
Since Instagram Feed Pro 6.14.0, Reels open in Swipe View instead of the lightbox. The Enable Swipe View for Reels setting, on the Advanced tab, is on by default. Photos and regular videos still open in the lightbox, and feeds with the lightbox turned off aren’t affected.
To learn more, see our guide on viewing Instagram Reels in Swipe View.
Next, we’ll look at one of the library snippets in detail.
Vertically Centering the Caption on Hover
One of the Smash Balloon snippets is named Vertically center Instagram caption on hover. It centers the caption text vertically when someone hovers over a post.
To use it, click Use Snippet on its card in the Snippets tab. To add the code yourself instead, put it inside the sbi_custom_js function from the Custom JavaScript section. The code uses $, so add the var $ = jQuery; line at the top of the function.
$('.sbi_hover_top').each(function(){
var $self = $(this);
$self.css({
'position' : 'absolute',
'top' : ( $self.parent().height() - $self.height() ) / 2
});
});
That’s it! You can now manage your Instagram feed customizations in WPCode, from ready-made snippets to your own CSS and JavaScript.
To learn how Reels open in your feed, see viewing Instagram Reels in Swipe View.
Frequently Asked Questions
Below, we’ve answered some of the most common questions about the WPCode integration.
Do I need WPCode to use Instagram Feed?
No. The Snippets tab and the one-click migration are the only parts of the plugin that use WPCode. Code that is still saved in the Custom CSS and Custom JS boxes continues to be added to your pages. Instagram Feed Pro has marked those boxes as deprecated, so we recommend moving that code to WPCode.
Does the free version of Instagram Feed have the Custom CSS and Custom JS boxes?
Yes. In the free plugin, both boxes always show on the Feeds tab. The Snippets tab and the one-click migration come with Instagram Feed Pro.
Do I need to buy WPCode?
No. The install button downloads the free WPCode plugin from WordPress.org. If WPCode Pro is already installed on your site, the plugin uses that one instead.