Title: Usage inside loop / template
Last modified: April 12, 2022

---

# Usage inside loop / template

 *  [kees78](https://wordpress.org/support/users/kees78/)
 * (@kees78)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/usage-inside-loop-template/)
 * For other people who want to auto-create the galery within a template file, you
   can find the shortcode id like this:
 *     ```
       $gallery_full = get_post_meta(get_the_ID(),'_easy_image_gallery_v2',true);
       $gallery_id = $gallery_full[0]['SHORTCODE'];
       ```
   
 * Now you have in variable $galleryid the number of the shortcode.
    In your template
   file, lets say single.php you can use the following:
 *     ```
       if( function_exists( 'easy_image_gallery' ) ) {
           echo do_shortcode('[easy_image_gallery gallery='.$gallery_id.']'); }
       ```
   
 * Good luck with it!
    -  This topic was modified 4 years, 1 month ago by [kees78](https://wordpress.org/support/users/kees78/).

The topic ‘Usage inside loop / template’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/easy-image-gallery_9da6b0.svg)
 * [Easy Image Gallery](https://wordpress.org/plugins/easy-image-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-image-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-image-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-image-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-image-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-image-gallery/reviews/)

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 0 replies
 * 1 participant
 * Last reply from: [kees78](https://wordpress.org/support/users/kees78/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/usage-inside-loop-template/)
 * Status: not a support question