Inserting the WooSlider into a .php Template file

WooSlider comes with a template tag (function) which can be used within your theme’s template files (if you don’t want to use the shortcode). The template tag looks like this:


There are 3 parameters in this template tag, all of which are optional. The first is an array of arguments. Using this array, you can override any of the settings on the main “Settings” screen, specifically for that slideshow, as well as specify the “slider_type” to be used (the default is “attachments”). An example of this parameter in use would be:

wooslider( array( 'slider_type' => 'posts', 'smoothheight' => 'true' ) );

The above example changes the slider type to “posts” and ensures that the smoothHeight functionality in FlexSlider is turned on.

What about customising the slider_type-specific settings? ↑ Back to top

This is where the second parameter comes in. To expand on our above example, we may want to get posts with only a specific post_tag, such as “featured”. To do this, we’d have to create a post_tag in the WordPress admin with the slug of “featured” (no quotes) and assign it to a few posts. From there, WooSlider’s template tag would look as follows:

wooslider( array( 'slider_type' => 'posts', 'smoothheight' => 'true' ), array( 'tag' => 'featured' ) ); 

This expands on our example above to include the “posts”-specific setting of filtering by a specified post_tag.

I don’t want to echo this… how do I assign it to a variable? ↑ Back to top

This is where our third, and final, parameter comes into play. To assign the rendered HTML to a variable, the template tag would need a third parameter of false (no quotes required). An example of this would be:

$my_slides = wooslider( array( 'slider_type' => 'posts', 'smoothheight' => 'true' ), array( 'tag' => 'featured' ), false );

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top