How to Link NextGEN Gallery Images to an Individual Page or Post in WordPress

When using the NextGen Gallery, sometimes you have to link the image to a post instead of a larger version.  I recently ran into this while working on a site for a client.

The steps after you have installed the NextGen Gallery are:

1.  In the admin, drop down to the NextGen options and head to  Gallery > Options > Effects > Set Javascript Thumbnail Effect to ‘None’

2. Install the NextGEN custom fields plugin.

3.  Navigate back to Manage Gallery and select on the gallery.  You’ll see a field to add links (image below – far right)

4. In the custom field put a link to one of your pages, posts, or another site.

5. Go to Plugins > Editor > Switch to NextGEN Gallery in the Drop down Box > and click on nextgen-gallery/view/gallery.php It is near the bottom of the lists. Or FTP direct to gallery.php.

6. Backup the file.

7. Find this:

and change it to this:

You are replacing imageURL with ngg_custom_fields[“Link”] so the image links to the URL in your custom field.

8. The [“Link”] will be the name of whatever you named the custom field.

9. It also includes a line that links the alttext or description of the image to the same page.

10. Save. Test.


  • Mark H 7 months ago Reply

    Great tut, I’ve recently run into this also. I’m using nexgen for other galleries on the same website though, and can’t change the overall settings to disable the Thumbnail Effect. I will definitely use this as a reference for the future! Thanks!

  • Ron Bolton 7 months ago Reply

    I’m new to WordPress so don’t know the framework that well.
    But is modifying plug-in code a good idea? What happens when the plug-in is updated? Is the modified code over writtem?

    I would like to be able to link a gallery from a post so that the user can see all the photos. As an example, the post would be a review of a competition and the gallery would be the photos taken of it.

    The above seems a lot of work to do this.

    • ombu 7 months ago Reply

      Yeah, it’s fine as long as you test it. I would always work on it locally, then once you’ve ran a couple tests and understand the logic of the plugin, then it should be fine.

  • igubak 7 months ago Reply

    Great it worked for me thanks

  • chris 6 months ago Reply

    For some reason this is not working for me. I have made all the changes specified but for some reason when I click on the images in my slideshow gallery it just fades to the next slide instead of going to the URL.
    Any ideas?

  • T. Francis Latif 5 months ago Reply

    Hi Ombu,

    I tried the code and it seems I have done it wrong (somewhere). I don’t know about css coding, so I’m pretty sure I did something wrong.

    Is there anyway you can help me with this? Thank you.

  • Scott Leone 5 months ago Reply

    You say to find the code beginning with … but there is no such code in the file, nor is there a gallery.php in the FTP.

  • Chris 4 months ago Reply

    Thanks for this it works a treat. I had to make some mods so that it didn’t apply to all galleries in my website, a bit messy bit I only want one particular gallery to work like this, all the others I’d like to work as standard.

    Here’s what I used…

    <a href="ID == 13){ echo $image->ngg_custom_fields[“Links”]; } else { echo $image->imageURL; } ?>” title=”description ?>” thumbcode ?> >

    Hope this helps someone out (-:

  • Chris 1 month ago Reply

    Is there a way to make this work on the full size image, not the thumbnails? I want my thumbnails to still open a larger image, and then I want the large image to open an external link.

  • Brian 1 month ago Reply

    Your images are broke on this page. I’m not sure what to edit in the plugins/nextgen-gallery/nggallery.php. I don’t see the file nextgen-gallery/view/gallery.php. Maybe your on a different version?

  • Brian Steck 7 weeks ago Reply

    It seems that NextGen Gallery has updated their plugin and the gallery.php file is no longer where it was. Does anyone have an clues as to where this code has been moved to?

Submit a Comment