NextGen Custom Fields plugin: display the custom fields outside the gallery template.

When using the NextGen Custom Fields plugin to create custom fields for your NextGen Gallery’s images and galleries, use the tags below to display these custom fields in the gallery template (gallery.php or gallery_yourtemplate.php):

For image custom fields, use the following tag:
<?php echo $image->ngg_custom_fields["Your Field Name Here"]; ?>

For gallery custom fields, use the following tag:
<?php echo nggcf_get_gallery_field($gallery->ID, "My Gallery Field Name Here"); ?>


However, when you venture outside of the gallery template, these tags won’t work. Below are the tags needed to call the custom fields anywhere outside of the gallery template:

To show a gallery custom field:
<?php echo nggcf_get_gallery_field(1, “Gallery Field Name”); /* where 1 is the gallery id */ ?>

If you are inside the foreach in the album template, you can do this:
<?php echo nggcf_get_gallery_field($gallery->gid, "Gallery Field Name"); /* This will show the "Gallery Field Name" custom field for all galleries in the template */ ?>

To show an image custom field:
<?php echo nggcf_get_field(123, "Image Field Name"); /* where 123 is the ID of the image you want the custom field to show for */ ?>

If inside a foreach loop:
<?php echo nggcf_get_field($image->pid, "Image Field Name"); /*This will show the "Image Field Name" custom field for all images in the template?>


To display the custom fields of the preview images of the galleries in an album template: just replace $image->pid with $gallery->previewpic so the code would be:
<?php echo nggcf_get_field($gallery->previewpic, "Field Name"); ?>

For the album’s preview image, it should be:
<?php echo nggcf_get_field($album->previewpic, "Field Name"); ?>



Credits: Shauno



  1. H.Walker
    Posted January 24, 2010 at 2:50 pm | Permalink

    Sorry if this is not relevant to your post, but I thought you might be able to help…again.

    Is it possible for a non-selfhosted blog to add an option below to comment box, such as the one you have, that says: Notify me of new posts via email?


    • Gnocchi
      Posted January 24, 2010 at 8:44 pm | Permalink


      I think that is a standard feature of blog. Are you sure that your blog doesn’t have that?


  2. Posted November 28, 2010 at 8:29 pm | Permalink

    Do you know if i can put custom fields in a nextgen gallery which is show as a slideshow? i can’t put the code ngg_custom_fields[“Your Field Name Here”]; ?> because i dont find where i have to put it when is a slideshow.


%d bloggers like this: