Wooslider – Template tags explained

Ok, let me get this out of the way first…I love Wooslider.

It’s an awesome, configurable and very flexible slider for WordPress. The only negative thing I have to say about it is this..

They don’t make it very clear how to use the template tags for anyone who wants to embed this thing in a template file.

So I’m going to try and clear it up for you. This page explains how to create template tags for Wooslider.

The documentation does explain how to embed shortcodes, and shortcodes are your clue to how the template tags work. They’re basically the same thing.

The page you really need to be looking at before you start, is the Wooslider shortcodes page. This page contains all the actions you can tell Wooslider to do in your template tags.

But how do you write your template tags?

Some typical template tags are provided on the getting started page…but it’s not immediately clear what does what. I’ll explain.

An empty Wooslider template tag looks like this:

wooslider();

If you are writing this as PHP it looks like:

<?php wooslider(); ?>

Each time you add a set of shortcodes inside the () you have to assign them to one of the ‘array’ groups, of which there are three. This is important. The actions will only work if you put them in the correct array group.

  1. In the first one, add any shortcode from General settings, Control Settings, or Button settings on the Wooslider shortcodes page.

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

  2. In the second one, add anything from the ‘specific parameters’ shortcodes on the Wooslider shortcodes page.

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

  3. In the third one, I have no idea what to do…I’ve never needed it and i don’t know what it does. Leave your best guess in the comments below :D

Now put it all together:

Use the standard template tag format to add all the shortcodes you require. Here’s one I wrote earlier:

<?php wooslider( array( ‘slider_type’ => ‘posts’, ‘smoothheight’ => ‘true’), array( ‘category’ => ‘homepage-feature-post’, ‘overlay’ => ‘full’, ‘link_title’ => ‘true’, ‘layout’ => ‘text-bottom’ ) ); ?>

This tag reads as follows…

First array (Settings options) set slider type to posts, make the slider resize with smoothheight to the size of the image.

Second array (Parameters options) set category to ‘homepage-feature-post’, set overlay to full, turn on link title and put the text at the bottom.

Pretty easy huh? You can now paste this shortcode into the relevant place in your index.php template or wherever you want the slider to display!

Hope it helps.

This post was written by

avatarJim O – who has written posts on SuperCreatives.
Hi I'm Jim and I run SuperCreatives which is basically me tapping at a keyboard and sometimes talking to people and working on stuff that helps people sell, communicate or promote things online. If you need to sell, communicate or promote things online...get in touch!

Email

9 comments

  1. avatar Ben Zukrel says:

    Why not just use the default shortcodes like this

    Note that you can set multiple categories and tags using comma separated
    also just make sure that the plugin is running.

  2. avatar Jim O says:

    Hi Ben, shortcodes are perfect for in page stuff but can they work in a template?

  3. avatar Ben Zukrel says:

    they work perfect with template. I did post example however the php code will not show. (wrap it in php code)
    if (function_exists(‘wooslider’)) echo do_shortcode(‘[wooslider tag="artwork" slider_type="posts" layout="text-right" display_excerpt="false"]‘)

  4. avatar Jim O says:

    Thanks Ben! Just changed mine to:

    < ?php if (function_exists('wooslider')) echo do_shortcode('[wooslider category="homepage-feature-post" slider_type="posts" layout="text-bottom" display_excerpt="true" smoothheight="true" overlay="full" link_title="true"]'); ?>

    And it works perfectly! Don’t know why I didn’t try that first :D

  5. avatar thomas says:

    Hi, thanks for this helper. Works for me except I’m not able to change the image size. I’m using

    ‘posts’, ‘smoothheight’ => ‘true’ ), array( ‘tag’ => ‘featured’, ‘size’ => ‘medium’, ‘overlay’ => ‘natural’, ‘link_title’ => ‘true’ )); ?>

    Am I missing something

    Thanks

  6. avatar Jim O says:

    Looks right to me Thomas. Try using the shortcodes in the comment above, so your code would be:

    < ?php if (function_exists('wooslider')) echo do_shortcode('[wooslider tag="featured" slider_type="posts" smoothheight="true" overlay="natural" link_title="true" size="medium"]'); ?>

  7. avatar Eddie H. says:

    Hi Jim, thanks for posting about this! The information available through woo and online for directly inputting it into a template file using template tags is almost non-existent. I have very limited knowledge of php and all of this stuff but would like to get a wooslider as the banner image on the free woo themes Mystile theme. I added a new slide (Home) with a few images in the slider settings and tried to add into the index.php file but nothing shows up. How am I supposed to direct the php to show the slider I created in the settings? So confused, argh!

    thanks for any and all help….

  8. avatar Alex says:

    Like Eddie H. I’d like to see a solution for the index.php of Mystile theme. Admit that I am beginner php, trying and failing to find a solution.

  9. avatar Jim O says:

    Sorry Eddie, I meant to respond to this. And Alex, thanks for commenting and reminding me about this thread :D

    I added a new post because my reply got a bit long.

    http://www.supercreatives.co.uk/2012/12/add-wooslider-php-to-your-index-template/

Post a comment

Copyright © SuperCreatives
Tidy stuff from Cardiff

Built on Notes Blog Core
Powered by WordPress