To create drop down menus in Thesis, you just add pages and assign a parent page to them. Then enable them in the Thesis options and voilà, you have a drop down menu. But what if you want to integrate some sort of fancy jQuery to the drop down menu so when you hover over the parent page, the list of child pages, or the sub menu, fades in elegantly. Well, here’s one solution.
For this tutorial, I’m using the Superfish menu jQuery plugin as I’ve used this before and is really easy to get working. Note that this tutorial is based off of version 1.4.8. Superfish is an enhanced Suckerfish-style menu jQuery plugin.
Step 1: Download the plugin
Visit this Superfish download page and download the zip file that contains all the files. I’m going to go through a basic installation, but you’re welcome of course to read more about the features on the Superfish website. The way I’m setting it up is based off the sample setup.
Step 2: Copy the files
For the basic installation which will result in a really nice, smooth jQuery drop down menu, copy these files into a folder called “js” in your custom folder inside the main Thesis folder:
- hoverIntent.js
- superfish.js
Now place this file in a folder called “css”, also inside the custom folder in your main Thesis theme folder:
- superfish.css
Finally, copy all the images that appear in the “images” folder into your images folder inside your Thesis custom folder.
Step 3: Add the code
Now that you’ve copied over the necessary files, you need to reference them. Paste this code into your custom-functions.php file:
function superfish() {
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<!-- superfish jquery menu -->
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/custom/js/hoverIntent.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/custom/js/superfish.js"></script>
<script type="text/javascript">
// initialise plugins
jQuery(function(){
jQuery('ul.menu').superfish();
});
</script>
<?php
}
add_action('thesis_hook_after_html','superfish');
And you’ll need to add this code to load the custom Superfish stylesheet. Add the following to the custom-functions.php file:
/* superfish stylesheet */
function superfish_stylesheet() {
?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/custom/css/superfish.css" media="screen">
<?php
}
add_action('wp_head','superfish_stylesheet');
You’re Done!
Believe it or not, that’s it. The plugin takes care of the rest. I’d recommend that you look at some of the settings available to you that reside inside the superfish.js file around line #85. You can enable or disable certain features like shadows and arrows and also set the delay of the sub menu.
Let us know how it worked out for you in the comments!
Was this post helpful? Consider subscribing to my blog via RSS or








































{ 26 comments… read them below or add one }
Awesome tutorial, thank you. I am getting a “jQuery(“ul.menu”).superfish is not a function error message. I tried the fix from here: http://terriswallow.com/weblog/2009/fix-jqueryul-sf-menu-superfish-is-not-a-function/
And I still get the error message, any thoughts or insights?
Thanks,
Mitch
Hi Mitch, I can’t really take a look to see if I can troubleshoot it for you because you hadn’t provided a link to the site in question. Maybe check to see that you aren’t loading jQuery twice.
Hey there,
My playbox is listed above.
Cheers,
M
Mitch, I had a look at your site and the problem is that the two .js files referenced in the tutorial cannot be found. They need to be included in that “js” folder. If you look at the code by viewing the source of the page, then scroll to the bottom, you’ll see the code you added which references these files. Well, when you visit that URL, the file is not there.
Duh, stupid me. I had the js folder in the incorrect location. Cheers!
Mitch recently posted..Lap Dances- Fundraisers- Sex Bloggers and Reid Gyrating for Speak Up! Feb 4th- NYC
Thanks for this. so easy!
Hi,
Superfish has nice nav-bar style that makes a nice two-tiered nav menu. Could you tell me how to integrate it into Thesis. I’ve added the superfish-navbar.css file after the main superfish.css file, as it says on their site,into the function superfish_stylesheet, but have problem adding the class sf-navbar to the parent ul along with the usual sf-menu class. Can you explain me how to make it work?
Hi Paul. Have you already followed the tutorial on this page? You’re asking how to integrate Superfish into Thesis, but that’s what this post is all about, so not totally following you here. Thanks for commenting.
Yes, your step-by-step tutorial is perfect and works very. But, it is for Superfish basic-style drop down menu. What I wanted to do was Superfish nav-bar-style menu. Here at the examples tab you can see the difference between those styles http://users.tpg.com.au/j_birch/plugins/superfish/#sample1
Superfish gives instructions on how to do it:
“To create a horizontal nav-bar with a horizontal second tier and optional vertical third tier, simply include the superfish-navbar.css file after the main superfish.css file and add the class sf-navbar to the parent ul along with the usual sf-menu class (space-separated, eg. class=”sf-menu sf-navbar”), and initialise as normal”
I think i’ve figured out the css part, but have problems with “add the class sf-navbar to the parent ul” part.
Hi Paul. I’d need to take a look at the site in question, but here are two short, quick, down and dirty answers for this:
1. I’d have to see the way you have the code structured but you might want to add a WordPress Menu for this because you have the ability to add a custom class to the wrapping div. But I don’t know offhand if the way you’re implementing this will work with the class on the wrapping div, or the parent UL as you indicated.
2. This might be the better solution for you. Add the class you need to the parent UL by using jQuery. I’ve explained a similar concept in this post on what to do if there’s no Thesis hook for that. But you’d need to use the .addClass() jQuery method explained here.
Hope that helps.
My playground is still local, so i’ll post here the code from custom_functions.php
This is what i’ve got:
function addClass_sfnavbar() { ?> <script> $(document).ready(function() { $("ul") .addClass(‘menu sf-navbar’); }); </script> <?php } add_action('wp_head','addClass_sfnavbar'); function superfish() { ?> <!– superfish jquery menu –> <script type="text/javascript" src="<?php bloginfo(‘template_directory’); ?>/custom/js/hoverIntent.js"></script> <script type="text/javascript" src="<?php bloginfo(‘template_directory’); ?>/custom/js/superfish.js"></script> <script type="text/javascript"> // initialise plugins jQuery(function(){ jQuery('ul.menu').superfish(); }); </script> <?php } add_action('thesis_hook_after_html','superfish'); /* superfish stylesheet */ function superfish_stylesheet() { ?> <link rel="stylesheet" type="text/css" href="<?php bloginfo(‘template_directory’); ?>/custom/css/superfish.css" media="screen"> <link rel="stylesheet" type="text/css" href="<?php bloginfo(‘template_directory’); ?>/custom/css/superfish-navbar.css" media="screen"> <?php } add_action('wp_head','superfish_stylesheet');what am i doing wrong?
I’d have to spend some time looking over all this code on your live site, but here’s what I usually do to troubleshoot something like this. If you can download a demo from the source that works, look at the HTML code behind the page that is working, and make sure that you replicate everything on that page in your Thesis theme using the appropriate hooks. Here are some things you can check:
Bottom line is that if you replicate the working demo completely, it should work.
Checked all 5. It seems that class sf-navbar is not being added. Here is the function from custom-function.php file that i’m using to add the sf-navbar class:
function add_sfnavbar() { ?> <script> $(document).ready(function() { $('ul.menu').addClass('sf-navbar'); }); </script> <?php } add_action('wp_head','add_sfnavbar');i checked it couple of times, but couldn’t find a mistake. Any help?
I tried this code myself and it works just fine. It’s adding the script to the head section. Here’s what could be the problem for you though. When I used your original code it had a coupel of invalid quote character characters. Check to make sure that you’re using a single quote wherever it is being used in the code. I’d paste this code in a text editor and the type over the single quotes to make sure. I used this exact code and it did work.
This is a great tutorial. I’m having the same issue as Paul, however, at http://yupana.ca. At present I’ve got very nice pulldown menus thanks to this tutorial, but can’t get the horizontal ones working. I’m aiming for the kind of functionality you see in the “nav-bar style”:
http://users.tpg.com.au/j_birch/plugins/superfish/#examples
I’m no coder – I’m an accountant. I generally scour for some good copy & paste options and then feel out the glitches.
My first issue is that I don’t understand the language of “simply include the superfish-navbar.css file after the main superfish.css file and add the class sf-navbar to the parent ul along with the usual sf-menu class (space-separated, eg. class=”sf-menu sf-navbar”), and initialise as normal.” on http://users.tpg.com.au
Second, here’s what I’ve got for code that’s gotten me to where I’m at now:
custom_functions.php:
function add_sfnavbar() { ?> $(document).ready(function() { $('ul.menu').addClass('sf-navbar'); }); <script type="text/javascript" src="/custom/js/hoverIntent.js"> <script type="text/javascript" src="/custom/js/superfish.js"> // initialise plugins jQuery(function(){ jQuery('ul.menu').superfish(); }); <link rel="stylesheet" type="text/css" href="/custom/css/superfish.css" media="screen"> <link rel="stylesheet" type="text/css" href="/custom/css/superfish-navbar.css" media="screen"> <?php } add_action('wp_head','superfish_stylesheet');The only changes I've made to any files that come with Superfish are the ones outlined in this tutorial. If you've got a minute, I'd love some feedback on where I might be going awry.
Hi Dave… I looked at what I believe is your site, but the code doesn’t seem to match up with what you pasted here. If you’d like just email me your WordPress site URL using the ‘Hire Me’ link in the menu and I’ll take a look. Please make sure you have at least one sub-sub menu, which is what I believe you’re trying to achieve here. Basically a three-tiered menu. I’ll see if I can take a look in the morning.
Will do, thanks.
The code didn’t paste properly at all, so I’ll do that.
Cheers!
Great tutorial. I don’t normally delve this deeply into JS and the like but I’ve been able to get this up and running on my testing site with minimal fuss in about an hour or so.
Had a few CSS tweaks to make but that was simple enough. The only problem I’m having now is with the positioning of the dropdown when it appears. Hovering over the top-level menu item causes the sub-menu overlay the top item. I need it to appear below the main nav bar. Can you point me in the right direction for changing the dropdown’s start point to make it appear below the main nav item please?
(PS My test site’s not publicly accessible but if you need to take a look at it to see what I mean feel free to email me at the address I’ve used to leave this comment and I’ll send you the link and a guest login. Thanks.)
Feel free to email me this information. You can use the contact link in the footer.
Hi – trying to work on this locally. I have all files, etc. on my desktop. I’ve copied the code as you wrote above. How do I actually activate the menus? If I already have something in place, how does it get changed to the superfish menus? I’m looking to also use the nav-bar menu.
Any direction is much appreciated.
Thanks and I hope you still see these comments!
There isn’t anything to “activate.” Just follow the directions above and it should just work. Thanks.
Can you suggest us a Good thesis skins , we are confused how we can design menu and all ..i like your blogs and turials , and also your blog looks and i think you can suggest us a good thesis skin
Techpur recently posted..How to Download all Facebook Albums Photos in Zip File
Just search on Google for Thesis Skins, and you should find a couple of the top skin sites out there. You could also have one custom designed for you so it looks exactly how you want with the functionality you want. If that’s of interest, click the “Hire Me” link at the top and submit the form. Thanks.
Thank you.
I followed your instructions exactly, but with that last bit of code to add this code to load the custom Superfish stylesheet my menu looked all funky. So i deleted that code and mine looks like: http://www.driostudio.com/services/marketing/
my question now is how do I edit those arrows and how do i fix it from shifting right after it drops down?
Rachel recently posted..Why website design?
So after a long time trying to get the nav-bar style to work, I’ve finally figured it out. And since this post helped me so much, I thought I might as well share the wealth.
(Please correct me if I’m wrong Thesis.blogs.com because I’m no coding expert).
Paul (above) was right with the coding part in custom_functions part. Here’s what I got:
function superfish() { ?> <script type="text/javascript" src="/custom/js/hoverIntent.js"> <script type="text/javascript" src="/custom/js/superfish.js"> // initialise plugins $(document).ready(function() { $('ul.menu').addClass('sf-navbar'); }); <link rel="stylesheet" type="text/css" href="/custom/css/superfish.css" media="screen"> <link rel="stylesheet" type="text/css" href="/custom/css/superfish-navbar.css" media="screen"> <?php } add_action('wp_head','superfish_stylesheet');The most important part though is the custom.css:
.custom .menu li { display:inline-block; float:none; }You'll have to play around with ".custom .menu" and ".custom .menu a" to customize it even more.
I hope others find this useful. Thanks Thesis.blogs.com
I tried superfish on one of my blogs (oyeludhiana.com) and it looks great…. still need to improve it a bit to give it “The” look but looks better than the default nav which thesis comes with
Amandeep Singh recently posted..Pinboard – Pinterest Like Responsive WordPress Theme [30% Off]