Title: Activating Custom Fields
Last modified: August 31, 2016

---

# Activating Custom Fields

 *  Resolved [ristretto6](https://wordpress.org/support/users/ristretto6/)
 * (@ristretto6)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/activating-custom-fields/)
 * A few years back, I started using the NextGen Custom Fields plugin to add a few
   effects to my gallery. Specifically, I added custom fields for the URL that the
   user is taken to when the click on an image, and the alt text that appears when
   they hover over the image.
 * After adding these custom fields via the plugin, and adding the appropriate values
   in my Gallery Manager for each of these fields, I then had to tweak my code in
   the gallery-caption.php file in order to make these custom fields activate.
 * Because I was changing this core php file, I had to save a copy of it and manually
   re-upload it every time I updated this plugin, because the plugin update would
   always overwrite this very crucial code — which I had very little understanding
   of, as I merely copied and pasted it from these help forums.
 * Lo and behold, I somehow lost that crucial gallery-caption.php file, and now 
   none of my custom fields are being applied in my galleries ([like this one](http://www.urbancraftuprising.com/summer-2016/),
   for example).
 * Can someone please help me restructure my gallery-caption.php code to make these
   URLs, captions, and alt text active again?
 * I know that the section of the code I had to replace looked something like what
   I’m going to paste below, but it must be a little bit off somewhere because when
   I upload that to my site, it’s not making anything display on my gallery.
 * <!– Thumbnails –>
    <?php $i = 0; ?> <?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” > ngg_custom_fields[“
   URL”]; ?>” title=”<?php echo $image->description ?>” <?php echo $image->thumbcode?
   > > <img title=”<?php echo $image->ngg_custom_fields[“Tagline”]; ?>” alt=”<?php
   echo $image->alttext ?>” src=”<?php echo $image-> thumbnailURL ?>” <?php echo
   $image->size ?> />
 * ngg_custom_fields[“URL”]; ?>”>
    <?php echo $image->alttext ?> </div>
 * [https://wordpress.org/plugins/nextgen-gallery/](https://wordpress.org/plugins/nextgen-gallery/)

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

 *  Thread Starter [ristretto6](https://wordpress.org/support/users/ristretto6/)
 * (@ristretto6)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/activating-custom-fields/#post-7296652)
 * Okay I’m sorry, I did just find my backup file. I’m going to post the code here
   for posterity in case this ever happens again! FYI, here is the code that activates
   the features I listed above:
 * <?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 ngg-template-caption” id=”<?php echo $gallery-
   >anchor ?>”>
 * <?php if ($gallery->show_slideshow) { ?>
    <!– Slideshow link –> <div class=”slideshowlink”
   > slideshow_link ?>”> <?php echo $gallery->slideshow_link_text ?>  </div> <?php}?
   >
 * <?php if ($gallery->show_piclens) { ?>
    <!– Piclense link –> <div class=”piclenselink”
   > piclens_link ?>”> <?php _e(‘[View with PicLens]’,’nggallery’); ?>  </div> <?
   php } ?>
 *  <!– Thumbnails –>
    <?php $i = 0; ?> <?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” > ngg_custom_fields[“
   URL”]; ?>” title=”<?php echo $image->description ?>” <?php echo $image->thumbcode?
   > > <img title=”<?php echo $image->ngg_custom_fields[“Tagline”]; ?>” alt=”<?php
   echo $image->alttext ?>” src=”<?php echo $image-> thumbnailURL ?>” <?php echo
   $image->size ?> />
 * ngg_custom_fields[“URL”]; ?>”>
    <?php echo $image->alttext ?> </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 Contributor [photocrati](https://wordpress.org/support/users/photocrati/)
 * (@photocrati)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/activating-custom-fields/#post-7296835)
 * [@ristretto6](https://wordpress.org/support/users/ristretto6/) – Thanks for sharing…
   for future reference it might be much easier to use a Gist, Pastebin, or CloudUp
   link to the code.
 * – Cais.

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

The topic ‘Activating Custom Fields’ is closed to new replies.

 * ![](https://ps.w.org/nextgen-gallery/assets/icon-256x256.png?rev=2083961)
 * [Photo Gallery, Sliders, Proofing and Themes - NextGEN Gallery](https://wordpress.org/plugins/nextgen-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextgen-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextgen-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/nextgen-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextgen-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextgen-gallery/reviews/)

## Tags

 * [caption](https://wordpress.org/support/topic-tag/caption/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)

 * 2 replies
 * 2 participants
 * Last reply from: [photocrati](https://wordpress.org/support/users/photocrati/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/activating-custom-fields/#post-7296835)
 * Status: resolved