Title: [Plugin: Lightbox Gallery] Does it work on php gallery code?
Last modified: August 19, 2016

---

# [Plugin: Lightbox Gallery] Does it work on php gallery code?

 *  [Pru](https://wordpress.org/support/users/pru/)
 * (@pru)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/plugin-lightbox-gallery-does-it-work-on-php-gallery-code/)
 * I was wondering if the Lightbox Gallery could be made to work outside the loop
   like in a command like this:
 * <?php echo do_shortcode(‘[gallery option1="value1"]‘); ?>
 * I am trying to display my gallery far below several custom content items so I
   cannot use the [gallery] short code.
 * [http://wordpress.org/extend/plugins/lightbox-gallery/](http://wordpress.org/extend/plugins/lightbox-gallery/)

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

 *  [Hiroaki Miyashita](https://wordpress.org/support/users/hiroaki-miyashita/)
 * (@hiroaki-miyashita)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/plugin-lightbox-gallery-does-it-work-on-php-gallery-code/#post-1271358)
 * In order to use the gallery shortcode outside the loop, you need to specify the
   post id. Something like this:
 *     ```
       <?php echo do_shortcode('[gallery id="15"]'); ?>
       ```
   
 * Please try it out.
 *  Thread Starter [Pru](https://wordpress.org/support/users/pru/)
 * (@pru)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/plugin-lightbox-gallery-does-it-work-on-php-gallery-code/#post-1271405)
 * Hi, it does not work if I just put the <?php echo do_shortcode(‘[gallery id="
   15"]‘); ?> outside the loop. If I put [gallery] inside the post loop, then the
   lightbox works both in the loop and outside the loop.
 * When I just use the code outside the loop without using [gallery] in the post,
   the three images in my gallery drop to a single column. When I click on them,
   it opens the image in the browser and shows nothing else. Sorry, I don’t have
   a live site or I’d give a link.
 * I am using the Single Post Template Plugin from [http://www.nathanrice.net/plugins/single-post-template/](http://www.nathanrice.net/plugins/single-post-template/)
   so maybe that is causing a problem, but I can’t test without that plugin since
   I use it to display my other content.
 *  [suzt808](https://wordpress.org/support/users/suzt808/)
 * (@suzt808)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/plugin-lightbox-gallery-does-it-work-on-php-gallery-code/#post-1271457)
 * I have this issue also…
    Ideally I would like to call the gallery dynamic from
   within a loop for a specific category. However the code above and the following
   code pulled from wordpress codex on the gallery also doesn’t work
 *     ```
       <?php
          				 //$gallery_shortcode = '[gallery id="' . intval( $post->ID) . '"]';
   
          				 //print apply_filters( 'the_content', $gallery_shortcode );
       				 ?>
       ```
   
 * The above didn’t work exactly, it pulled all the gallery images on the page in
   a column and once clicking on the images, it went to the image page versus lightbox.
 * I also tried
 *     ```
       <?php
          				  $gallery_shortcode = '[gallery]';
   
          				 print apply_filters( 'the_content', $gallery_shortcode );
       				 ?>
       ```
   
 * And that didn’t work either..
    Do you have a suggestion for pulling multiple 
   galleries within the loop ? Thanks in advance,

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

The topic ‘[Plugin: Lightbox Gallery] Does it work on php gallery code?’ is closed
to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [suzt808](https://wordpress.org/support/users/suzt808/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/plugin-lightbox-gallery-does-it-work-on-php-gallery-code/#post-1271457)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
