Sometimes the Instagram Feed plugin included with our themes might throw an error similar to this one:
Fatal error: Cannot use object of type WP_Error as array in site_url/wp-content/plugins/theme_name-instagram-feed/lib/theme_name-instagram-api.php on line XYZ
This may seem a bit alarming and hard to handle for a less experienced WordPress user, however there’s quite an easy and straightforward fix for this issue.
First off, seeing that this solution requires a small template file change, it is required that you connect to your server using your FTP credentials.
Then, navigate to this path: \wp-content\plugins\theme_name-instagram-feed\lib\
and open theme_name-instagram-api.php file found therein using a text editor.
Search for the function called fetchData found in that file using the CTRL + F functionality, or you can achieve this manually.
Find the variable $httpResponse and after the $limit variable and before the closing brackets “ ) ” add the following:
, array( 'timeout' => 120 )
This effectively means that you should replace this code:
$httpResponse = wp_remote_get( $this->apiURL . '/users/' . $this->userID . '/media/recent/?access_token=' . $this->accessToken . '&count=' . $limit);
With this one:
$httpResponse = wp_remote_get( $this->apiURL . '/users/' . $this->userID . '/media/recent/?access_token=' . $this->accessToken . '&count=' . $limit, array( 'timeout' => 120 ) );
You can see this in the screenshot below:
Depending on theme, this might need to be done twice.
In some rare cases, the timeout could be defined/set outside the $httpResponse variable, in which case it is only needed to increase the already set value.
In this example we used the timeout of 120, which corresponds to 120 seconds. You can of course use a smaller/higher value if you wish. The default value is 5 seconds.
After you’re done with editing, you should save the file and use it to override the one currently on your server.
Of course, in case you aren’t familiar enough with coding, feel free to submit a ticket and allow our support agents to do the suggested change in your behalf.