One of the most popular features to have in websites today is the “featured content slider” (or “featured post slider”). It gives people a glimpse into your better posts and can catch their attention right away. For these reasons, it was one of the first features I included in my latest premium Thesis skin.
Today I’m going to tell you how you can do it for your own Thesis site (if for some crazy reason you don’t use Thesis Magazine :p)
So without further ado, here’s how to add a jQuery-powered featured content slider to Thesis in 5 quick steps:
The Instructions
I’m using the s3slider as my slider of choice. It doesn’t have navigation buttons, but I find it quick, easy, and great at doing what it does. You can try experimenting with different sliders if you feel comfortable and want other functionality.
- Download the necessary file from the s3slider homepage (s3Slider.js) and then upload it to your website.
-
Turn on jQuery (Thesis Page Options > Javascript) and place
<script src="js/s3Slider.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $('#s3slider').s3Slider({ timeOut: 4000 }); }); </script>in the Additional Scripts section of the Thesis Site Options (where js/ is the directory of your s3lider.)
-
Add this to custom_functions.php:
add_action('thesis_hook_before_content', 'slider'); function slider() { if (is_home()){ ?> <div id="s3slider"> <ul id="s3sliderContent"> <?php $sub_loop_1 = new WP_Query('category_name=featured'); while ($sub_loop_1->have_posts()) : $sub_loop_1->the_post(); global $post; $post_image = get_post_meta($post->ID, 'thesis_post_image',$single=true); ?> <li class="s3sliderImage"> <a href="<?php the_permalink(); ?>"> <img src="<?php echo $post_image ?>" alt="<?php the_title(); ?>" /> <span><strong>Featured - </strong><?php the_title(); ?></span></a> </li><?php endwhile; ?> <div class="clear s3sliderImage" /> </ul> </div> <?php } } -
Add the following in custom.css:
/* SLIDER */ #s3slider { width: 580px; /* important to be same as image width */ height: 300px; /* important to be same as image height */ position: relative; /* important */ overflow: hidden; /* important */ margin-top: 35px; padding-bottom: 5px; margin-left: 1em; } #s3sliderContent { width: 580px; /* important to be same as image width or wider */ position: absolute; /* important */ top: 0; /* important */ margin-left: 0; /* important */ padding: 0px; } .s3sliderImage { float: left; /* important */ position: relative; /* important */ display: none; /* important */ } .s3sliderImage span { position: absolute; /* important */ left: 0; font: 21px/24px Helvetica, Arial, sans-serif; padding: 10px 13px; width: 100%; background-color: #000; filter: alpha(opacity=70); /* here you can set the opacity of box with text */ -moz-opacity: 0.7; /* here you can set the opacity of box with text */ -khtml-opacity: 0.7; /* here you can set the opacity of box with text */ opacity: 0.7; /* here you can set the opacity of box with text */ color: #fff; display: block; /* important */ bottom: 0; /* if you put top: 0; -> the box with text will be shown at the top of the image if you put bottom: 0; -> the box with text will be shown at the bottom of the image */ } .clear { clear: both; } - Create a category named “featured” and put the posts you’d like to have featured in that.
That’s it; you’re done. You now have a featured content slider on your homepage.
But what does it all mean!? A breakdown
Although following the above steps will have you up and running, learning some detail on what you’re doing will allow you to adapt this to other sliders and functions in the future.
add_action('thesis_hook_before_content', 'slider');
function slider() {
if (is_home()){
?>
This is the start of a function. It names it (slider) and places it before our content on our homepage.
<ul>
<?php $sub_loop_1 = new WP_Query('category_name=featured');
while ($sub_loop_1->have_posts()) : $sub_loop_1->the_post();
global $post;
$post_image = get_post_meta($post->ID, 'thesis_post_image',$single=true);
?>
This starts our loop, which will cycle through all the posts in the “featured” category (can be whichever category you’d like) and grabs the Thesis post image for display in a minute. Check out the Codex for more information on WordPress loops.
<a href="<?php the_permalink(); ?>">
<img src="<?php echo $post_image ?>" alt="<?php the_title(); ?>" />
<span><strong>Featured - </strong><?php the_title(); ?></span></a>
</li><?php endwhile; ?>
<div class="clear s3sliderImage" />
</ul>
This is our loop in action. It shows our post image and links it to the post. It also displays the title with “Featured – ” before it. You can learn more about WordPress template tags such as the_title here.
I hope you enjoyed the tutorial. If you have any questions, leave them in the comments and I’ll try my best to answer them. If you have any comments, leave them too, as I’d love to hear them. Thanks.
Stay Updated

You'll notice this site talks about the Thesis theme for Wordpress. Don't know what the heck that is? Find out.



{ 25 comments… read them below or add one }
#1 in the instructions: where in my website do I put the s3slider file?
Wherever you’d like. Just make sure that your script src in the 2nd step points to it. For that reason, it’d probably be quickest to place it in a folder called js in the root of your domain.
I know people like you (smart and all) hate people liking me asking questions. But at some point you had to learn too right? I really want to try this. The most I’ve done with downloads has been with plugins so I wasn’t sure where the js should go. Thanks for your patience in advance.
But… he told you where to put the js folder. The root of your domain. You don’t have to get snarky with him.
The root of your domain is the VERY FIRST area that’s in your public folder, the main part where all files and folders which are visible on the site are.
Make a new folder there, and call is js.
I think you may have forgotten to put the key in the ignition:
$(document).ready(function() {
$(‘#s3slider’).s3Slider({
timeOut: 4000
});
});
Wow. I sure did. Thanks.
It’s not working for me. I just have one big white spot. Please help.
Ditto. I double-checked I did everything right.
HI
Where should this “extra code” go? My slider doesn’t look good
Sorry, I should also have said it works like a dream (when you add that) and thanks for posting it. Very useful.
i have tried this about 15 times and cannot get it to work
i think the bit that i am having problems with is the custom_functions.php
sorry to be a pain, can you help?
If your having WP whiteout issues … see if adding a closing php tag to your custom_functions.php file helps …
On the last line of the file simply add ‘?>’
that may help
HTH …
is it possible to show all your recent posts as featured? I need slider to show recent posts as featured without adding them into “featured” category. Like dynamic content gallery it should pull last 6 recent posts. I don’t like dynamic content gallery plugin because my blog is running slow, but I need featured slider for thesis. I will be thankful if you guide me.
HI
I love this feature, but I want to have this on my front page and the blog itself on another page. When I set this through the WP reading settings the feature slider doesn’t work on either page.
Can you suggest how to do this on an alternative, static front page?
Hello.
I have also the problem of the “white box”. I followed the step by step approach but it does not work.
Also, someone could explain to me where (and if) we have to add the extra code show in the comments.
Thank you very much!!
Hi guys,
I followed exactly on what the guide says, but i am getting this error.
Parse error: syntax error, unexpected ‘}’ in /home/fitgeekm/public_html/atrashids.com/wp-content/themes/thesis_18/custom/custom_functions.php on line 25
do help
Hi,
I am doing lots of things right. But I do not know where to put
$(document).ready(function() {
$(‘#s3slider’).s3Slider({
timeOut: 4000
});
});
All I have is a big white space before the posts.
it’s doesn’t work for me
I did what this post said but there is a white space and in the code I see that the content is there, but in firebug it’s just hidden. Any idea? Here is where I am experimenting with it: http://www.startuploans.org/dev/
Nevermind. All you have to do is take out the display:none for .s3sliderImage
Hi guys,
I still have an issue with this. I did everything as described and moved the hook like “‘thesis_hook_before_header’”. I can see the spot for the slider but the post of the featured type isn’t showing. I can see that there is a small square with the name of the post over it but it just doesn’t show. Any idea’s?
Hi,
Thanks for the great tutorial but I would like to use this plugin to show specific pages instead of the last posts. I would also like for it to appear on a specific page instead of the posts page.
Any idea on how to do that?
Thanks in advance!
I’m having problem with css file. Css use:
filter: alpha(opacity=70); /* here you can set the opacity of box with text */
35.-moz-opacity: 0.7; /* here you can set the opacity of box with text */
36.-khtml-opacity: 0.7; /* here you can set the opacity of box with text */
37.opacity: 0.7; /* here you can set the opacity of box with text */
–> They don’t validate with css 2.1 and i check with css 3 that result is the same
Please help me.
Thanks you
in thesis how to embed expandable text- easy way
like a heading with expand button to read more in the same page (like a slider opens)
any script for it? please help
done everything and get this error
Fatal error: Cannot redeclare slider() (previously declared in /public_html/site/wp-content/themes/thesis_182/custom/custom_functions.php:4) in /public_html/site/wp-content/themes/thesis_182/custom/skins/thesismagazine/functions.php on line 254
{ 1 trackback }