Sometimes it’s the subtle things that count in regards to making your site stand out from the rest, and with that in mind… jQuery can be your best friend. There are a few light weight jQuery based scripts I tend to use over and over again when developing new WordPress themes. These are very simple techniques that can be applied in under five minutes to just about any theme.
If you are looking for a practical guide to WP Template Tag, with detailed descriptions and sample code, I suggest you to take a look at the WordPress Visual Cheat Sheet designed by Antonio Lupetti.
Fade Anything
This is a tiny little script that can be used to fade pretty much any element on a hover event such as post thumbnails, a block of text or even an entire div. Of course… all of these techniques assume that you have already loaded jQuery into your theme. If not, edit header.php found within your theme folder and place…
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
directly above the <?php wp_head(); ?> tag to pull the latest version of jQuery. Once you have jQuery loaded, simply add the following to your theme header.php file.
<script type="text/javascript">
$(function () {
$('.fade').hover(function() {
$(this).fadeTo("fast", 0.5);
}, function() {
$(this).fadeTo("fast", 1);
});
});
</script>
All you need to do after that is add class="fade" to any element you want to be faded on hover. This is a very simple CSS free effect that really does impress for less. To get a better idea of how this looks on the front end, head over to my Video Flick theme demo and hover over any post thumbnail.
Simple Tips
Styled tooltips are one of those things that your users are either going to love or hate. However, I feel that in moderation they can be a very effective way to save valuable real-estate and eliminate information overload by removing unnecessary text. There are literally hundreds of jQuery based tooltip plugins to choose from, but I tend to veer toward the ones that are truly minimal and efficient. For this tutorial, lets use the “aToolTip” plugin by Ara Abcarians which can be found here.

After downloading the tooltip script, upload it to your theme scripts folder on your web server. If there is no scripts folder in your theme directory, simply create one. Since we are dealing with WordPress, once again, you will need to edit header.php and paste…
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/atooltip.jquery.js" type="text/javascript"></script>
somewhere above the <?php wp_head(); ?> tag. Directly below that, lets define how we are going to call the tooltip functionality by adding this…
<script type="text/javascript">
$(function () {
$('a.tip').aToolTip();
});
</script>
Now that the required scripts have been added we can move on to theme integration. For starters lets just add an excerpt to your post titles. Edit index.php and find…
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
Replace that with…
<a class="tip" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_excerpt(); ?>"><?php the_title(); ?></a>
That’s it… your finished. Of course you may want to style your tips to match your theme which is pretty easily done by adding and editing the following to your theme style.css file.
.tooltip {
background: #FFFFFF;
border:1px solid #E6E6E6;
width: 300px;
margin:0;
padding:6px 12px 6px 12px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
.tooltip .tooltip-content {
position:relative;
margin:0;
padding:0;
}
To get a better idea of how this looks on the front end, head over to my Tapp Jobs theme demo and hover over any post title.
by
Jason Schuller is a digital creative professional living and working in Seattle Washington. He primarily designs and builds themes and plugins for the popular WordPress publishing platform. Jason is also an entrepreneur and the founder of two startups including 

November 30, 2009 at 1:35 pm
You’re supposed to use wp_enqueue_script() to include jQuery.
November 30, 2009 at 2:36 pm
Will definitely keep that in mind when writing future tutorials.
November 30, 2009 at 2:19 pm
Any way of fading UP? Everything would normally be, say, 50% opacity and then on rollover 100%?
Great tips! Thx!
November 30, 2009 at 3:21 pm
I’ve just put together my top 10 WP plugins that will make visitors happy.
http://www.paulpetch.com/2009/11/30/generating-wordpress-traffic-with-plugins/
November 30, 2009 at 3:29 pm
Thanks for these two sweet tips.
Tell me this: if one reverses the “amounts” in the fading script, would it work in reverse?
…fadeTo(”fast”, 1);
…
….fadeTo(”fast”, 0.5);
Reverse as in anything tagged with the .fade div would have the 50% fade applied, and a rollover would bring it back to full strength?
Actually, I’m going to try it out now anyway. :)
Thanks again!
Michael
p.s. is “gravity forms plugin” included with the purchase of that Tapp Jobs theme in your second example?
November 30, 2009 at 3:47 pm
The switching of the values “woorked”, sort of.
On initial page load, items classed as .fade were in full force, but at mouseover/mouseout, they changed to the faded out value. And subsequently then, on mouseOver, they faded in to 100 percent, mouse out, back to the fade.
Jay (et al), I’m sure there’s something else out there that would set up the pre-fade-out nature on pageLoad. Someone soon I’m sure will probably post it here. :)
Again Jason, kudos for a nice bit of tips.
Michael
November 30, 2009 at 10:01 pm
love it. thanks jason.
December 1, 2009 at 10:29 am
Thanks… more to come.
November 30, 2009 at 10:10 pm
I’ll second the comment that wp_enqueue_script() should be used. When there’s “best practice” option, use it! In this case, your code may result in conflicts, say, if plugin calls a different version of jQuery.
Disclaimer: My older plugins still do it the old way, so I don’t practice what I preach – yet. It’s on the list of things to fix up.
December 1, 2009 at 10:29 am
I’m going to even “third” that comment myself. I will be the first to admit that I have plenty to learn, and today was one of those days where I learned something new.
December 1, 2009 at 1:30 am
Great tips. I am gonna try it out now. Thanks.
December 1, 2009 at 4:01 pm
Have fun…
December 1, 2009 at 2:58 pm
As mentioned by other commenters, wp_enqueue_script() is the way to go; http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/ shows how to use the function and how to put jQuery into “no conflict mode” if you need to include another framework that aggressively hijacks the $ syntax.
Also, the Digging into Wordpress site is a great resource in general for WP users.
December 1, 2009 at 10:52 am
Thanks for the link…
December 1, 2009 at 6:35 pm
hi jason. nice tips. how can i add the class ‘fade’ to the blogroll links, if using images? because in wp panel > links > doesnt have a field ‘class’ to links. im using a widget in footer with links. i try but havent sucess in how do it. the class works for all div links, not for each image. sorry for my english. thanks!
December 4, 2009 at 11:20 am
Great “fade” technique! Thanks for the advice Jason.
December 14, 2009 at 12:05 am
Great stuff. Thanks!
December 20, 2009 at 10:36 pm
The Correct CSS for aTootTips is
Best Regards
Jauhari