Title: [Plugin: NextGEN Custom Fields] Custom Fields Not Correctly Linking
Last modified: August 19, 2016

---

# [Plugin: NextGEN Custom Fields] Custom Fields Not Correctly Linking

 *  [teeriddle](https://wordpress.org/support/users/teeriddle/)
 * (@teeriddle)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/)
 * Hi,
 * I’m having a slight issue with NextGen Custom Fields. I place the link within
   the text box that I want the images to point to, but after I publish the post(
   or save the gallery) all the images link to the post that the gallery is in, 
   and not the URLs I specified in the image custom fields.
 * The strange thing is I’m using NG and NG Custom Fields on 2 different sites. 
   On one site it is working perfectly, the other site it’s doing the weird linking
   to the post thing.
 * I have gone over both installations and both are identical as far as I can tell
   so I’m pretty stumped why one is working and the other not.
 * Any suggestions? I feel that’s it’s something stupid that I’m overlooking somewhere,
   just can’t figure out where.
 * NextGen version 1.7.2
    NextGen Custom Fields 1.1.2 Wordpress 3.0.3

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [shauno](https://wordpress.org/support/users/shauno/)
 * (@shauno)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825881)
 * Hi teeriddle
 * That sounds very strange. If it’s linking back to the page it’s on, that means
   there is nothing actually in the `href=""` part.
    Chances are you’ve miss-spelled
   the name of the field I would think. Case is important with that type of thing
   too.
 *  Thread Starter [teeriddle](https://wordpress.org/support/users/teeriddle/)
 * (@teeriddle)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825884)
 * Hi shauno, thanks for your reply.
 * Yeah it’s strange. Using FireBug if I inspect the images in the gallery the image
   link appears as
 * `a href title="title I set in gallery"`
 * It’s just like that – no link address.
 * I double checked the spelling of the field names in the Custom Fields admin area
   and in the gallery.php code and both are identical.
 * The only thing I can think of is it is related to the theme. The site that galleries
   are functioning properly is a different theme that the one where gallery links
   are bonked.
 *  Plugin Author [shauno](https://wordpress.org/support/users/shauno/)
 * (@shauno)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825893)
 * Can you past the code of the gallery.php here? Maybe I can spot something, but
   I’m really stumped.
 *  Thread Starter [teeriddle](https://wordpress.org/support/users/teeriddle/)
 * (@teeriddle)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825908)
 * Here’s the gallery.php
 *     ```
       <?php  
   
       /** Template Page for the gallery overview  Follow variables are useable :  	$gallery     : Contain all about the gallery 	$images      : Contain all images, path, title 	$pagination  : Contain the pagination content   You can check the content when you insert the tag <?php var_dump($variable) ?>  If you would like to show the timestamp of the image ,you can use <?php echo $exif['created_timestamp'] ?> **/ ?> 
   
       <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>  
   
       <div class="ngg-galleryoverview" id="<?php echo $gallery->anchor ?>">  <?php if ($gallery->show_slideshow) { ?>
   
       <!-- Slideshow link -->
       <div class="slideshowlink">
       <a class="slideshowlink" href="<?php echo $gallery->slideshow_link ?>"> 			<?php echo $gallery->slideshow_link_text ?>
       </a> 	</div>
       <?php } ?>
       <?php if ($gallery->show_piclens) { ?> 
   
       <!-- Piclense link --> 	
   
       <div class="piclenselink">
        		<a class="piclenselink" href="<?php echo $gallery->piclens_link ?>">
       			<?php _e('[View with PicLens]','nggallery'); ?> 		</a> 	</div> <?php } ?> 	 	
   
       <!-- Thumbnails -->
       <?php foreach ( $images as $image ) : ?>
       <div id="ngg-image-<?php echo $image->pid ?>" class="ngg-gallery-thumbnail-box" <?php echo $image->style ?> >
       <div class="ngg-gallery-thumbnail" >
       <a href="<?php echo $image->ngg_custom_fields["customlink"]; ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
       				<?php if ( !$image->hidden ) { ?>
       <img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> /> 				<?php } ?>
       </a>
       </div>
       </div>
       <?php if ( $image->hidden ) continue; ?> 	<?php if ( $gallery->columns > 0 && ++$i % $gallery->columns == 0 ) { ?>
       <br style="clear: both" />
       <?php } ?>
       <?php endforeach; ?>
         	 	<!-- Pagination -->
       <?php echo $pagination ?>
       </div>
       <?php endif; ?>
       ```
   
 *  Plugin Author [shauno](https://wordpress.org/support/users/shauno/)
 * (@shauno)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825911)
 * I just copied and pasted that into my gallery.php, and created an custom field
   for the gallery displayed named `customlink`, and it worked perfectly.
 * I’m not sure what else to do to debug this. Is the site live? If not, you can
   put the following debug code in for me, and paste the results here. It might 
   give us a clue, or a point in the right direction:
 * Replace line 23 (the start of the `foreach` loop) with this:
 *     ```
       <?php foreach ( $images as $image ) : ?>
       <?php
       print("<pre style='font-family:verdana;font-size:13;color:#000;z-index:99999;background:#ccc;'>");
       print_r((is_array($image->ngg_custom_fields) ? $image->ngg_custom_fields : 'Hook failed!'));
       print("</pre>");
       continue;
       ?>
       ```
   
 * That will output a grey block inplace of each image, with either an array of 
   details, or the text “Hook failed!”.
 * Let me know the results, and maybe we can find something.
 *  Thread Starter [teeriddle](https://wordpress.org/support/users/teeriddle/)
 * (@teeriddle)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825914)
 * I replaced the code that you mentioned above and received this:
 *     ```
       Array
       (
           [customlink] => http://www.amazon.com
       )
       Array
       (
           [customlink] => http://click.linksynergy.com/fs-bin/click?id=5CWAlVpbUHA&subid=&offerid=193067.1&type=10&tmpid=5728&RD_PARM1=http%3A%2F%2Fwww.petmountain.com%2Fproduct%2Freptile-food-bowls%2F11442-107634%2Fexo-terra-exo-terra-feeding-dish.html
       )
       Array
       (
           [customlink] => http://click.linksynergy.com/fs-bin/click?id=5CWAlVpbUHA&subid=&offerid=193067.1&type=10&tmpid=5728&RD_PARM1=http%3A%2F%2Fwww.petmountain.com%2Fproduct%2Freptile-food-bowls%2F11442-502719%2Fexo-terra-worm-dish-mealworm-feeder.html
       )
       Array
       (
           [customlink] => http://click.linksynergy.com/fs-bin/click?id=5CWAlVpbUHA&subid=&offerid=193067.1&type=10&tmpid=5728&RD_PARM1=http%3A%2F%2Fwww.petmountain.com%2Fproduct%2Freptile-food-bowls%2F11442-107633%2Fexo-terra-exo-terra-water-dish.html
       )
       ```
   
 * That is a gallery of four images and it returned the links to each image in the
   gallery. It looks like it is outputting fine, yes? But the images still go to
   the post that contains the gallery.
 * For grins, I inserted a gallery at this page:
    [Gallery Test](http://www.beardeddragonlife.com/vitamins-minerals-bearded-dragons/)
 * Scroll towards the bottom of the post, just above the “You may also like-” heading.
   You will see four images in a gallery. Click those images and you’ll see what
   I’m talking about.
 * Thanks for your time.
 *  Plugin Author [shauno](https://wordpress.org/support/users/shauno/)
 * (@shauno)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825918)
 * Wow, that’s exactly what should output. I have no idea how it isn’t being inserted
   into the href! It’s a Christmas miracle 🙂
 * Try replacing line 26 (without that other debug code, it should be the open a
   tag), with this:
 * `<a href="<?php echo $image->ngg_custom_fields["customlink"]; ?>" title="<?php
   echo $image->description ?>" <?php echo $image->ngg_custom_fields["customlink"];?
   >`
 * That should output the link above of the image.
 *  Thread Starter [teeriddle](https://wordpress.org/support/users/teeriddle/)
 * (@teeriddle)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1825922)
 * That worked on my test site! I haven’t tried it on the live site yet.
 * I did need to add the second > at the end of the code 😉
 * `<a href="<?php echo $image->ngg_custom_fields["customlink"]; ?>" title="<?php
   echo $image->description ?>" <?php echo $image->ngg_custom_fields["customlink"];?
   > >`
 * But that appears to have fixed the issue.
 * Thanks so much for all your time and work on getting this resolved.
 * Happy Holidays!
 *  [courtneyjoy](https://wordpress.org/support/users/courtneyjoy/)
 * (@courtneyjoy)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1826001)
 * I know you just had this discussion on here, but it doesn’t matter what custom
   link I enter into the field at the right of each image in the gallery, it still
   links to the original image URL.
 * I don’t really understand PHP, so I’m not sure if my situation would be different
   from the one you’ve already addressed.
 * Thanks,
 * Courtney Joy
 *  [superfried](https://wordpress.org/support/users/superfried/)
 * (@superfried)
 * [15 years ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1826100)
 * Hello
 * I have also been having trouble with this with a site I am developing for a DJ
   friend. I am a graphic designer, ok with html and css, but new to php.
 * I have now replaced the custom fileds solution I found elsewhere with this one,
   including the extra amend by shauno. Instead of my images linking to a post they
   do not link at all. When you click them it activates the next slide. This makes
   me think that perhaps I have selected something in the options that is overriding
   the custom fields. Or one of my other plugins is causing a conflict.
 * Also, when I look at the code using chrome developer tools, there is no link 
   showing wrapped around the images.
 * In the fields for each image I have simply inserted a standard google url:
    [http://www.google.co.uk](http://www.google.co.uk)
 * Is this correct or do you also need the ‘href’ or to include a complete link 
   code including the ‘img src’ etc?
 * The development url is:
 * [http://www.atmosoft.co.uk](http://www.atmosoft.co.uk)
 * Any help would be gratefully received!
 * Superfried
 *  [superfried](https://wordpress.org/support/users/superfried/)
 * (@superfried)
 * [15 years ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1826106)
 * Hi don’t worry about this question by me anymore.
 * Used this slideshow instead.
 * [http://slideshow.hohli.com/](http://slideshow.hohli.com/)
    [http://wordpress.org/extend/plugins/a-slideshow/](http://wordpress.org/extend/plugins/a-slideshow/)
 * Simply put the code in a text widget where you can simply wrap the image code
   with link tags. Clean and simple.
 * Thanks
 * Superfried

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘[Plugin: NextGEN Custom Fields] Custom Fields Not Correctly Linking’ 
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/nextgen-gallery-custom-fields.svg)
 * [NextGEN Custom Fields](https://wordpress.org/plugins/nextgen-gallery-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextgen-gallery-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/reviews/)

 * 11 replies
 * 4 participants
 * Last reply from: [superfried](https://wordpress.org/support/users/superfried/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-custom-fields-not-correctly-linking/#post-1826106)
 * Status: not resolved