Title: [Plugin: NextGEN Gallery] Using galleries with custom fields?
Last modified: August 19, 2016

---

# [Plugin: NextGEN Gallery] Using galleries with custom fields?

 *  [Jimi Wikman](https://wordpress.org/support/users/mortfiles/)
 * (@mortfiles)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-using-galleries-with-custom-fields/)
 * I am building up a portfolio using wordpress and I would like to add screenshots
   using the gallery, but in a way so I can hardcode it into the post template rather
   than adding a gallery tag in the post itself. I would like to use custom fields
   to add a gallery id so that I can set the correct gallery for each post/projekt.
 * Any pointers as to how to make this?

Viewing 1 replies (of 1 total)

 *  Thread Starter [Jimi Wikman](https://wordpress.org/support/users/mortfiles/)
 * (@mortfiles)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-using-galleries-with-custom-fields/#post-862762)
 * Found the solution 🙂
 *     ```
       <?php
          $meta_id = $wp_query->post->ID; /* stores your post id in a variable */
   
       /* This stores the defined gallery ID into a variable.  Setting this to true makes sure it returns a string instead of an array */
          $meta_gallery_id = get_post_meta( $meta_id, 'meta_gallery_id', true );
          if( $meta_gallery_id != '' ) {
       	   $meta_gallery = '[gallery=' . $meta_gallery_id . ']';
       	   $meta_gallery= apply_filters( 'the_content', $meta_gallery );
       	   echo $meta_gallery;
       	 }
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: NextGEN Gallery] Using galleries with custom fields?’ is closed
to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [Jimi Wikman](https://wordpress.org/support/users/mortfiles/)
 * Last activity: [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-using-galleries-with-custom-fields/#post-862762)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
