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 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 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.
- The topic ‘Added Shortcodes!’ is closed to new replies.