Title: Conflict with shortcode
Last modified: September 20, 2016

---

# Conflict with shortcode

 *  Resolved [LS](https://wordpress.org/support/users/lsterling03/)
 * (@lsterling03)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/conflict-with-shortcode/)
 * Simple lightbox breaks when used on the same page with the following shortcode:
 * Do you know why? The shortcode itself works fine, and so does everything else
   on the page. I see no errors in the console. But Simple Lightbox is not adding
   the data attributes to the gallery links when this shortcode is present on the
   page.
 *     ```
       function staffshortcode( $atts ) {
   
           extract(shortcode_atts(array('num' => '-1','category' =>''), $atts));
   
           $staffquery = new WP_Query( array(
             'post_status' => 'publish',
       	  'post_type' => 'staff',
       	  'orderby' => 'menu_order',
       	  'order' => 'ASC',	
       	  'posts_per_page' => -1,
       	  'tax_query' => array(
       		array(
       			'taxonomy' => 'department',
       			'field'    => 'slug',
       			'terms'    => $category
       		),
       	     ),
       	));
   
          // the loop
           if ( $staffquery->have_posts() ) : 
       	while ( $staffquery->have_posts() ) : $staffquery->the_post(); 
   
                 $temp_title = get_the_title($post->ID);
       	  $temp_excerpt = get_the_excerpt($post->ID);
       	  $temp_thumb = get_the_post_thumbnail($post->ID,'resident');
   
                 $output .= '<div class="row"><div class="col-sm-4">'.$temp_thumb.'</div>
                   <div class="col-sm-8"><h3>'.$temptitle.'</h3>'.$temp_excerpt.'</div></div><hr />';
   
       	endwhile; wp_reset_query(); endif;
   
          return $output;
   
       }
       add_shortcode("staff", "staffshortcode");
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [Archetyped](https://wordpress.org/support/users/archetyped/)
 * (@archetyped)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/conflict-with-shortcode/#post-8204229)
 * Hi, shortcodes are processed in the `the_content` filter hook. If your shortcode
   handler runs code that _also_ applies that filter, then it will steamroll the
   state of the in-progress `the_content` filter, stopping other plugins (such as
   SLB) from running.
 * To prevent this from happening, you need to backup the existing filter state 
   before running your code, and then restore the filter state afterwards.
 * Take a look at `apply_filters()` code for more details on its inner workings,
   and [see here for details on an example of backing up the filter state](https://github.com/websharks/wp-snippets/pull/2)
   in another shortcode that was inadvertently stopping plugins hooked into the `
   the_content` filter from running.

Viewing 1 replies (of 1 total)

The topic ‘Conflict with shortcode’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/simple-lightbox.svg)
 * [Simple Lightbox](https://wordpress.org/plugins/simple-lightbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-lightbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-lightbox/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-lightbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-lightbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-lightbox/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Archetyped](https://wordpress.org/support/users/archetyped/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/conflict-with-shortcode/#post-8204229)
 * Status: resolved