Title: [Plugin: WP jQuery Lightbox] rel=&quot;lightbox&quot; not working with do_shortcode function
Last modified: August 19, 2016

---

# [Plugin: WP jQuery Lightbox] rel="lightbox" not working with do_shortcode function

 *  [andreu](https://wordpress.org/support/users/andreu/)
 * (@andreu)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-jquery-lightbox-rellightbox-not-working-with-do_shortcode-function/)
 * Hi!
 * I’ve been using this plugin in some projects and it’s amazing, thank you for 
   your work!
 * I have a little problem with a current project. Like always, when I use the plugin
   with the gallery shortocde like `[gallery link="file"]` it works fine inside 
   the content.
 * But now, I’ve found a problem using the gallery shortcode ousite the content.
   I’m running the gallery this way with the do_shortcode function: `echo do_shortcode('[
   gallery link="file"]');`
 * Looking at the plugin code, I see that the filters which add the `rel="lightbox"`
   attribute are:
 *     ```
       add_filter('the_content', 'jqlb_autoexpand_rel_wlightbox', 99);
       add_filter('the_excerpt', 'jqlb_autoexpand_rel_wlightbox', 99);
       ```
   
 * This filters are only running on the_content and the_excerpt, so I’m trying to
   add a filter to the do_shortcode function this way but it’s not working fine:
   `
   add_filter('do_shortcode', 'jqlb_autoexpand_rel_wlightbox', 99);`
 * Do you know how can I make the do_shortcode function work?
 * Thanks!!

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

 *  [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-jquery-lightbox-rellightbox-not-working-with-do_shortcode-function/#post-1962969)
 * Don’t know, but it’s a great question. I haven’t thought of the possibility of
   running filters manually like that.
 * I’ll look into this for the next release.
 *  [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-jquery-lightbox-rellightbox-not-working-with-do_shortcode-function/#post-1963010)
 * I’ve looked into this and the correct way to manually output a post gallery and
   apply lightbox to it is this;
 *     ```
       $gallery_output = do_shortcode('[gallery link="file" id="398"]');
       echo jqlb_autoexpand_rel_wlightbox($gallery_output);
       ```
   
 * Notice post ID being set manually in the gallery shortcode.
 * For the next release (out within an hour) I’ve added a convenience function –`
   jqlb_apply_lightbox`. Just feed it some content and a unique ID (number or string)
   for the set of pictures.
 *     ```
       $gallery_output = do_shortcode('[gallery link="file" id="398"]');
       	if(function_exists("jqlb_apply_lightbox")){
       		echo jqlb_apply_lightbox($gallery_output, "any ID");
       	}
       ```
   
 *  [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-jquery-lightbox-rellightbox-not-working-with-do_shortcode-function/#post-1963011)
 * Perhaps the longest hour of my life. 🙂
 * [Version 1.3 is out](http://wordpress.org/extend/plugins/wp-jquery-lightbox/),
   with [a public method to run the Lightbox regexp on any string](http://wordpress.org/extend/plugins/wp-jquery-lightbox/installation/).

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

The topic ‘[Plugin: WP jQuery Lightbox] rel="lightbox" not working with do_shortcode
function’ is closed to new replies.

 * ![](https://ps.w.org/wp-jquery-lightbox/assets/icon-256x256.png?rev=3274178)
 * [LightPress Lightbox](https://wordpress.org/plugins/wp-jquery-lightbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-jquery-lightbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-jquery-lightbox/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-jquery-lightbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-jquery-lightbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-jquery-lightbox/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [ulfben](https://wordpress.org/support/users/ulfben/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-jquery-lightbox-rellightbox-not-working-with-do_shortcode-function/#post-1963011)
 * Status: not resolved