Title: Added Shortcodes!
Last modified: August 20, 2016

---

# Added Shortcodes!

 *  Resolved [gpspake](https://wordpress.org/support/users/gpspake/)
 * (@gpspake)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/added-shortcodes/)
 * I typically don’t like to bother with templates if I don’t absolutely have to
   so I whipped up some short code support for this thing. Thanks, as usual to Smashing
   as their guides are awesome. This shortcode puts the slider in a div and allows
   you to pass 2 arguments: the div class and the slider id. And now it’s working
   great!
 * I added all this to functions.php With [Hal’s instructions](http://halgatewood.com/flexslider-hg/)
   but you could probably wrap this up in the plugin just as easily.
 * so here goes…
 * First of all this is all Hal’s stuff, tweaked for my site of course.
 *     ```
       <?php
   
       function set_flexslider_hg_rotators()
       {
         $rotators = array();
         $rotators['paintings'] = array( 'size' => 'paintings-rotator' );
         $rotators['drawings'] = array( 'size' => 'drawings-rotator' );
         $rotators['photography'] = array( 'size' => 'photography-rotator' );
         $rotators['sculpture'] = array( 'size' => 'sculpture-rotator' );
         return $rotators;
       }
       add_filter('flexslider_hg_rotators', 'set_flexslider_hg_rotators');
       add_image_size( 'paintings-rotator', '550', '250', true );
       ```
   
 * Then we bring in the shortcode magic (Thanks again for [this smashing guide](http://wp.smashingmagazine.com/2012/05/01/wordpress-shortcodes-complete-guide/)
   which has been helpful more than once.)
 *     ```
       add_shortcode('gsflexslide', 'gsflexslide_function');
       function gsflexslide_function($atts){
          extract(shortcode_atts(array(
             'slider_id' => 'paintings',
             'class' => 'gsflexslide',
          ), $atts));
   
          $return_string = '<div class="'.$class.'">';
          if(function_exists('show_flexslider_rotator'))  { show_flexslider_rotator( $slider_id );};
          $return_string .= '</div>';
   
          wp_reset_query();
          return $return_string;
       }
       ?>
       ```
   
 * And the shortcode:
    [gsflexslide] defaults to ‘paintings with a class of .gsflexslide[
   gsflexslide class=”whatever” slider_id=”whatever”] selects the whatever slider
   and puts it in a div with the class .whatever.
 * And that’s it.
 * I hope this helps someone. I’m brand new to php so if I made any mistakes feel
   free to let me know.
 * Now that I have it on my pages, I need to figure out how to make it slide instead
   of fade. I’ll share when I do.
 * [http://wordpress.org/extend/plugins/flexslider-hg/](http://wordpress.org/extend/plugins/flexslider-hg/)

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

 *  [kwatts22](https://wordpress.org/support/users/kwatts22/)
 * (@kwatts22)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/added-shortcodes/#post-3367749)
 * This is a good way and one of the most simple ways to added it. Otherwise you
   would have to edit the index.php page and add it into your template.
 *  Plugin Author [Hal Gatewood](https://wordpress.org/support/users/halgatewood/)
 * (@halgatewood)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/added-shortcodes/#post-3367822)
 * I’ll add a custom widget and shortcode to the plugin by default in the coming
   weeks. Thanks for this.
 *  Plugin Author [Hal Gatewood](https://wordpress.org/support/users/halgatewood/)
 * (@halgatewood)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/added-shortcodes/#post-3367824)
 * A shortcode has been added to the latest version of the plugin.
 * [flexslider slug=homepage]

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

The topic ‘Added Shortcodes!’ is closed to new replies.

 * ![](https://ps.w.org/flexslider-hg/assets/icon-256x256.png?rev=970026)
 * [Responsive WordPress Slider - HG Slider](https://wordpress.org/plugins/flexslider-hg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/flexslider-hg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/flexslider-hg/)
 * [Active Topics](https://wordpress.org/support/plugin/flexslider-hg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/flexslider-hg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/flexslider-hg/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Hal Gatewood](https://wordpress.org/support/users/halgatewood/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/added-shortcodes/#post-3367824)
 * Status: resolved