Support » Plugin: Responsive Photo Gallery » PHP warning: Warning: Invalid argument supplied for foreach()

  • Resolved mattsson



    I’ve recently taken over maintenance of a new website, which is using the latest version (3.4.4) of Responsive Photo Gallery plugin. I’ve created a development website, which runs PHP version 7.0.22. When visiting the gallery, e.g. using the link above, I see this PHP warning instead of the photos: Warning: Invalid argument supplied for foreach() in /home/(obfuscated)/public_html/urban/wp-content/plugins/responsive-photo-gallery/responsive-gallery-short-code.php on line 127.

    The live site is at the same version of Responsibe Photo Gallery plugin, but its PHP version is only 5.5.38. When I visit the photo gallery page there ( I see the photos below the header image.

    We would like to update the PHP version of our web server. But we don’t want to break our photo gallery in the process. Can you advise on how to fix this PHP warning at the development website?

    I looked for this error online, I do see it at one other website:

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mattsson


    I have an idea as to what might cause this error. Maybe when I cloned the live site to create the dev site, some file paths might not have been properly updated?

    I was able to create a NEW photo gallery, here: Once I added new and different photos to this new gallery, the PHP warning message disappeared.

    You may close this issue. However I hope this thread will help others who see this PHP warning, to understand want is causing it.


    Plugin Support weblizar_support


    Hi mattsson,

    – We checked this issue and please update this file in your plugin

    – Download the new file from here.

    – Path is

    plugin directory/responsive-gallery-short-code.php

    – Replace this file with the new shared file.

    – And also update the gallery with new images, one time more.

    – Please notify us after the update.


    Thread Starter mattsson


    Hello Weblizar,

    Thank you for your quick response and for the new file. I installed it. Then, I added a new image to my test photo gallery, it seems to work OK. However the old code worked just fine with my test gallery as well.

    Looking at the original gallery, the PHP error message no longer appears, I only see the 9 blank photos. So that is an improvement.

    A tip, the new file you gave me contained a blank line at the top, so at first I got PHP errors on every admin page “Warning: Cannot modify header information – headers already sent by (output started at /home/obfuscated/public_html/urban/wp-content/plugins/responsive-photo-gallery/responsive-gallery-short-code.php:1) in /home/obfuscated/public_html/urban/wp-admin/includes/misc.php on line 1116.”

    I removed the blank line then the error messages no longer appeared.

    Another tip, the new file contains no version information (at least not near the top of the file where I expect to see it). So there’s nothing to identify which plugin it belongs to or which version, or that it’s a special patch.

    One more thing, it turns out that the website owner actually no longer needs this photo gallery on the website, so I’m about to remove the link to it.

    Thanks again for your help.

    Plugin Support weblizar_support


    Hi mattsson,

    – Thank you so much for the best feedback
    – In next update, we will fix this
    – And your issue is resolved we are so happy
    – If you like our support please review us.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP warning: Warning: Invalid argument supplied for foreach()’ is closed to new replies.