In my previous article I discussed how more information could be added to the images in the NextGEN Gallery by using the NextGEN Custom Fields plugin.
I installed and activated the plugin, created a new custom field, and showed the code that was used to display the new field with the images.
What I still need to discuss is where the code should go in the NextGEN Gallery template file and how to link to individual posts or pages. So, here we go.
- Install the NextGEN Custom Fields plugin, if you haven’t done so already.
- Create a new custom field for images.
- In the custom field put a link to one of your pages, posts, or another site. I made mine a link to a the specific page for each item in my portfolio.
- 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.
- Make a copy of this file before you start it.
- Starting at Line 41 (in my copy) is the following block of code:
- I changed the code to the following so that the image was linked to the page I designated in the new custom field and so that the description was linked to the same page.
Basically, you are replacing imageURL with ngg_custom_fields[“Link”] so the image links to the URL in your custom field.
- Keep in mind that [“Link”] will be the name of whatever you named your custom field.
- I also added the last line that links the alttext or description of the image to the same page.
- Since you are editing a template file, the changes will be lost if you don’t save them before upgrading the plugin. This is a bit of a hack but it is a way to link images in the NextGEN Gallery to individual posts or pages.
Here are some of the images in my portfolio, which demonstrates how this works.
Note: This information came from the WordPress support forums and the plugin developer. I used the information to do this write-up.
photo credit: mugley
Did you enjoy this article? I can assist you with your WordPress or Facebook project. Contact me and I will provide you with an estimate. You can also connect with me on Facebook or follow me on Twitter. If you are looking for Hosting, WordPress Theme, Newsletter or other recommendations, please view my detailed list.
233 Responses to “How to Link NextGEN Gallery Images to an Individual Page or Post in WordPress”
- NextGEN Custom Fields Plugin: Add More Information about an Image in the NextGEN Gallery | (Anti) Social Development
- derivate.co.uk | Blog | Gallery feature
- Link NextGen Gallery Images to a Page or Post using WP Shopping Cart Plugin « Derek Tacconelli Blog
- How to Link Images in a NextGen Gallery Album to a Post or Page | WordPress and Facebook Consultant | (Anti) Social Development