• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Home
  • About
  • My Blogs
    • Photoblog
    • Knots
    • WP.com tips
kristarella.com

kristarella.com

Happiness Engineer at Automattic, lover of knitting, crochet, sci-fi and more

  • Presentations
  • Plugins
    • Exifography
  • Contact
You are here: Home / WordPress / Themes / Thesis / Drop-up menu in Thesis 1.6

Drop-up menu in Thesis 1.6

11 November 2009 by kristarella

Contents
  1. The menu code
    1. What the code does
  2. A bit of javascript for positioning
    1. What the javascript does
  3. A bit of CSS to wrap up

Yes, drop-up is a bit of an oxymoron. Technically you pull something up and drop something down, but since we talk about drop-downs so much, and the effect of what I’m about to show you happens with the same amount of “gravity”, and I’m not an language pedant (all of the time)… it’s okay.

I was asked how one might create a menu to go in the footer and I thought, hey why not show my blog a bit of love? So, what I’m going to do here is make a drop-up menu listing archives, categories and recent posts, using built in WordPress template tags and Thesis menu classes.

Drop-up Nav

This has been tested in Safari and Firefox on Mac and IE6, IE7 and IE8 on Windows. There may be some z-index issues for sub-sub-menus in IE7 and IE8, sub-sub-menus don’t really work at all in IE6 because they’re not wrapped with tables, and position of the drop-up was not perfect in IE6. I wasn’t able to solve these issues. In many cases these bugs might not be visible at all (e.g., if you don’t have any sub-sub-menus), or acceptable sacrifices if you don’t care much about IE6, which I don’t.

The lovely thing about menus in Thesis 1.6 is that all the hard work of CSS dropdowns are done for you, and since the navigation has a class of “menu” (rather than an ID of “tabs”), it’s perfectly okay to reuse this class elsewhere.

The menu code

This code needs to go in custom_functions.php (which is now conveniently accessible via the built in ‘Custom File Editor’).

function custom_footer_nav() {
?>
<ul id="footer_nav" class="menu">
	<li><a href="">Archives<!--[if IE 7]><!--></a><!--<![endif]-->
	<!--[if lte IE 6]><table><tr><td><![endif]-->
		<ul class="submenu">
			<?php wp_get_archives(); ?>
		</ul>
	<!--[if lte IE 6]></td></tr></table></a><![endif]-->
	</li>
	<li><a href="">Categories<!--[if IE 7]><!--></a><!--<![endif]-->
	<!--[if lte IE 6]><table><tr><td><![endif]-->
		<ul class="submenu">
			<?php wp_list_categories('title_li='); ?>
		</ul>
	<!--[if lte IE 6]></td></tr></table></a><![endif]-->
	</li>
	<li><a href="">Recent Posts<!--[if IE 7]><!--></a><!--<![endif]-->
	<!--[if lte IE 6]><table><tr><td><![endif]-->
		<ul class="submenu">
			<?php wp_get_archives('type=postbypost&limit=5'); ?>
		</ul>
	<!--[if lte IE 6]></td></tr></table></a><![endif]-->
	</li>
</ul>
<?php
}
add_action('thesis_hook_after_footer','custom_footer_nav');

What the code does

The code is wrapped in a PHP function so that we may insert it below the footer using the thesis_hook_after_footer hook.
The HTML that builds the menu is an unordered list, with each list item containing another unordered list. Each sub-list is populated with list items from the template tags wp_get_archives and wp_list_categories, which retrieve links to archives (monthly, daily, post by post, whatever you specify) and categories and present them as list items.

It’s essential that the first unordered list have class="menu" so that it inherits all the built-in dropdown function of the Thesis navigation menu.

Before and after each sub-list is

<!--[if IE 7]><!--></a><!--<![endif]-->
	<!--[if lte IE 6]><table><tr><td><![endif]-->

and

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

Those are there to tell Internet Explorer not to finish the parent link before the sub-list (because IE6 only allows the :hover selector on links) and for IE6 to wrap the sub-list in a table (for positioning).

A bit of javascript for positioning

The above code will give a functional dropdown menu, but we were after a drop-up menu. To achieve that we need to position the submenus above the parent links by the same number of pixels as their height. This is not currently possible in CSS for dynamic elements (with automatically created height). You could give them a fixed height, but I’m going to use a bit of jQuery to detect the height and then position the submenu.

This should also go in custom_functions.php

if ( !is_admin() ) {
	wp_deregister_script('jquery'); 
	wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2'); 
	wp_enqueue_script('jquery');
}

function add_to_head() {
?>
<script type="text/javascript">
	$(function() {
		$("#footer_nav ul.submenu").each(function() {
			var listHeight = $(this).height();
			$(this).css("top", "-" + listHeight + "px");
		});
		$("#footer_nav > li").click(function() {
			return false;
		});
	});
</script>
<?php
}
add_action('wp_head','add_to_head');

What the javascript does

The first bit with deregister, register and enqueue script adds a Google hosted jQuery library to the pages on your blog (but not the admin pages in the dashboard).

The function add_to_head() adds some jQuery to the head of your site. It finds the submenu in our footer navigation (#footer_nav ul.submenu) and detects its height in pixels ($(this).height()) then applies CSS of top:-height; so that the submenu is positioned by its full height above the menu.

$("#footer_nav > li").click(function() {
	return false;
});

That just makes sure that nothing happens when you click on the top-level links of the footer menu because in this example they don’t go anywhere. You can remove this if you intended to link the top links to real pages.

A bit of CSS to wrap up

This goes in custom.css. All it does is rearrange some of the borders and margins that makes the dropdown navigation lists line up properly, so our drop-up lists line up better. If you have navigation borders set to 0 in the Design Options, you probably don’t need this CSS at all.

.custom #footer_nav {border-bottom:0; border-top:1px solid #ddd;}
	.custom #footer_nav li {margin-bottom:0; margin-top:-0.1em;}
		.custom #footer_nav li ul {border-bottom:0; margin-top:0;}
			.custom #footer_nav ul.children {margin-top:0.1em;}

If you need further info on the syntax of PHP, XHTML or CSS to understand the info above, please check out Tizag tutorials and W3 Schools.

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on Pocket (Opens in new window) Pocket

Like this:

Like Loading...

Related

Filed Under: Thesis, Tutorials Tagged With: CSS, geek, jQuery, PHP

Reader Interactions

Comments

  1. Khai says

    11 November 2009 at 18:47

    I really thank you for the help you’ve provided.

  2. Mat Packer says

    11 November 2009 at 19:30

    That’s quite nifty!

  3. mktanny says

    11 November 2009 at 19:40

    i m addicted to ur posts!!!!!!!!
    Almost bookmarked each page of ur blog

  4. Miguel says

    14 November 2009 at 12:58

    Excellent, thanks for sharing. I was thinking about this when 1.6 first arrived. 🙂

    -Mig

  5. Alison Moore Smith says

    24 November 2009 at 07:23

    Great post. Thanks for the info.

    You aren’t kidding about how easy drop-downs are in Thesis. I spent days creating a contextualish menu thingee on a client site a few years ago. Now, with Thesis, it took no time. Kills me!

  6. David Alexander says

    2 December 2009 at 05:00

    Keep up the good work Kristarella, what little you know of how much you have helped me 🙂 Love your interesting articles and tutorials, keep pushing the boundaries matey 🙂

    David

  7. Robin says

    4 December 2009 at 22:08

    It’s unique menu of drop down at footer, not usually.

  8. Shubham says

    7 December 2009 at 02:42

    hey….loved the menu..!!

  9. Suzi Piker says

    2 January 2010 at 05:33

    Kristarella,

    Would you be so kind as to shed some light on what we should do if we used the wonderful custom solution you instructed in the past for pre 1.6 versions? I just want to make sure all of my menu css still gets pulled in.

    Thank you!

  10. kristarella says

    3 January 2010 at 09:56

    Suzi — The best thing to do is to keep your old CSS on hand, but remove it from the CSS file, then copy as much as you can into the new settings on the Design Options page; you can control colours and adjust borders from those settings. Then any CSS you have that you can’t use through the Design Options can be copied back into your custom.css file and change .custom #tabs or .custom ul#tabs to .custom ul.menu.

  11. brian tinsley says

    19 January 2010 at 05:20

    Hi,

    I am trying to add my subpages to my menu, for some reason, I got the About me to add contact under it, but i can’t seem to get it to add any other pages.

    Any ideas? You look like a genius with this!
    Brian 🙂

  12. kristarella says

    19 January 2010 at 10:14

    Brian — Usually it’s a case of forgetting to add the pages to the nav menu after assigning them as a child page. That’s what I usually do anyway.

  13. hanep says

    25 January 2010 at 01:15

    Good one! I was looking for this tutorial all this while. Thanks 🙂

  14. Pete says

    28 January 2010 at 14:37

    Happy New Year!

    Once again a great post and I love you Skins. On this site I see you have transparent navigation tabs. Is this easy to do and if so could you please let me know how.

    Thanks. Pete

  15. kristarella says

    28 January 2010 at 22:20

    Pete — I believe all you need in custom.css is .custom .menu li a {background:transparent;}.

  16. Pete says

    28 January 2010 at 22:31

    You’re right! Like everything in life, it’s so simple when you know how :o) Keep up the inspirational work and thanks for a very quick response.

  17. WC says

    1 February 2010 at 19:49

    Thanks for the tutorial, I had some fun with it 🙂
    Now I have a crazy question, do you know how to bring the page nav down to the footer using this drop up technic?

  18. kristarella says

    1 February 2010 at 21:05

    WC — you can use wp_list_pages() the same way wp_list_categories() is used, or if you wanted to duplicate your thesis navigation with pages and categories down the bottom you could use thesis_nav_menu(); instead of all the code in the function (but if you did it wouldn’t have the id “footer_nav” anymore, you’d need a different identifier).

  19. WC says

    2 February 2010 at 12:12

    Hey, I used thesis_nav_menu(); in the function and it’s showing up. (I put a around, it seems to work…)
    It looks like the second level drop up is off 1 cell with to the top.. (the child pages)… Not sure what’s the best way to fix it
    … Also, how do I get rid of the top menu bar completely?
    Thanks 🙂

  20. WC says

    2 February 2010 at 12:57

    Hi I just added this to the custom.css, it fixed the offset 🙂
    .custom #footer_nav li ul li ul {border-bottom:0; margin-top:30px;}

  21. kristarella says

    2 February 2010 at 14:44

    WC — When using thesis_nav_menu() it would be better not to have it inside another ul, which is why I said you’d use it instead of all the code in the function, otherwise you end up with a menu inside a menu. Anywho, if you have it working for you, that’s good.

    To remove the top navigation you need remove_action('thesis_hook_before_header','thesis_nav_menu'); in custom_functions.php.

  22. WC says

    2 February 2010 at 15:24

    Hi, I put it in a div and give it an id (footer_nav)
    thanks for your help! 🙂

  23. WC says

    2 February 2010 at 15:25

    btw, do you have a suggestion to make it into something like this?
    http://www.bennadel.com/blog/1.....eBook-.htm

  24. kristarella says

    2 February 2010 at 15:49

    WC — Essentially all you would need is .custom #footer_nav {position:fixed; bottom:0; }, but as he says in that link, IE doesn’t always play nicely. Not sure what value you’d need to center it perhaps looking up “CSS position” on W3 Schools will tell you.

  25. Suzi Piker says

    28 March 2010 at 07:03

    I’ve upgraded to Thesis 1.6 and WP 2.9.1 and I’m attempting to make my horizontal sub work again instead of using dropdowns. Here is how it looked before: http://tinyurl.com/yj3tx25

    Here is how it looks now … subnav not showing up by default and only as a drop down: http://truenewzealand.com/ourtrips

    As you’ve suggested, I’ve changed: .custom ul#tabs to .custom ul.menu

    Here is my code:
    CSS: http://tinyurl.com/y96gk7x
    Custom functions pasted into .txt: http://tinyurl.com/yagkyjo

    I’m guessing it’s in the custom functions … perhaps a remnant of the old tutorial? Thank you as always.

  26. kristarella says

    29 March 2010 at 08:20

    Suzi — For starters, remove the height CSS from #nav_area, the alignment is all wrong because of it.

    In layout.css is the CSS

    .menu ul, .menu ul li { width: 15em; }
    	.menu ul ul, .menu :hover ul :hover ul { left: 15em; }

    You need to counteract that in your custom.css somehow and also cause the submenu items to float left because they no longer inherit that from the parents.

    .custom ul.menu ul {width:100%; left:0;}
      .custom ul.menu ul li {float:left; width:15em;} /* change this width to suit your taste, it's the submenu tab width */
  27. Jimena says

    31 March 2010 at 13:27

    dear kris,
    i need HELP!!!!
    i’m really stuck with this. i designed a drop up menu JUST with css, but it doesn’t seem to work on IE. i have tried everything and it still doesn’t work.
    is there any way you could help me out? i’ve been working on this for over 4 days now, and i don’t seem to be able to find the solution.

    this is my php:

    <?php if ($area == "testtres") { ?> <div id="menu" style="padding-right:61px;"> <ul> <li> <a href="#" class="interviews"> <img src="../img/interviews_on.gif" width="93" height="22" alt="" /> </a> <ul> <li><a href="http://&lt;?php echo $_SERVER[‘HTTP_HOST’]; ?>/httpdocs/Site/interviews_edward-furlong.php" class="<?php echo($subarea == "furlong" ? "on" : "") ?>">EDWARD FURLONG</a></li> <li><a href="http://&lt;?php echo $_SERVER[‘HTTP_HOST’]; ?>/httpdocs/Site/interviews_peter-coyote.php" class="<?php echo($subarea == "coyote" ? "on" : "") ?>">PETER COYOTE</a></li> <li><a href="http://&lt;?php echo $_SERVER[‘HTTP_HOST’]; ?>/httpdocs/Site/interviews_slash.php" class="<?php echo($subarea == "slash" ? "on" : "") ?>">SLASH</a></li> </ul> </li> </ul> </div> <? } else { ?> <div id="menu" style="padding-right:61px;"> <ul> <li> <a href="#" class="interviews"> <img src="../img/interviews_off.gif" width="93" height="22" alt="" /> </a> <ul> <li><a href="http://&lt;?php echo $_SERVER[‘HTTP_HOST’]; ?>/httpdocs/Site/interviews_edward-furlong.php" class="<?php echo($subarea == "furlong" ? "on" : "") ?>">EDWARD FURLONG</a></li> <li><a href="http://&lt;?php echo $_SERVER[‘HTTP_HOST’]; ?>/httpdocs/Site/interviews_peter-coyote.php" class="<?php echo($subarea == "coyote" ? "on" : "") ?>">PETER COYOTE</a></li> <li><a href="http://&lt;?php echo $_SERVER[‘HTTP_HOST’]; ?>/httpdocs/Site/interviews_slash.php" class="<?php echo($subarea == "slash" ? "on" : "") ?>">SLASH</a></li> </ul> </li> </ul> </div> <? } ?>

    and this is my CSS
    #menu{padding:0;margin:0;z-index:22px;background-color:#000000;text-align:center;}#menu ul{padding:0;margin:0;list-style-type: none;}#menu ul li {float:left; position:relative;}#menu ul li ul {visibility:hidden; position:absolute;} #menu li{position: relative;float: left;list-style: none;margin: 0;padding:0;}#menu li a{width:93px;height: 22px;display: block;font-size:9px;text-decoration:none;text-align: center;line-height: 20px;background-color:#000000;font-size:9px;color: white;}#menu li a:hover{color: #808080;}#menu ul ul{position: absolute;top: -67px;visibility: hidden;}#menu ul li:hover ul{visibility:visible;}#menu li a.on{color: #808080;}

    i would really appreciate your help.

    best.

  28. kristarella says

    31 March 2010 at 13:55

    Jimena — In what way does it not work in IE, and which versions of IE?
    Have you tried looking at dropdown menus on CSS Play. There’s a funny little IE table hack that might be the key.

  29. Jimena says

    31 March 2010 at 14:22

    kris, thanks for your reply.
    it doesn’t show my submenu, nothing appears. in every IE.
    i’m looking into the link you sent me right now.

    best.

  30. kristarella says

    31 March 2010 at 15:00

    Jimena — If nothing is showing, it might be that it is hidden behind another element, in which case you need to apply z-indexes.

  31. Jimena says

    31 March 2010 at 15:05

    thank you so much! you’ve been super helpful!!!!!!

  32. Suzi Piker says

    6 April 2010 at 04:02

    Thanks for your suggestions on getting the horizonal sub-nav to work again (29 March 2010) post Thesis 1.6 upgrade. Unfortunately, even with the suggestions made they still stubbornly only appear as a drop down. Perhaps in a future tutorial you may update horizontal sub nav information for current Thesis iterations. I’ll stay tuned 🙂

  33. kristarella says

    6 April 2010 at 08:44

    Suzi — I missed the fact that you wanted it to show up all the time. Try .custom ul.menu li.current ul {visibility:visible;}. You’ll probably need to tweak some margins to accomodate it.

  34. Suzi Piker says

    6 April 2010 at 09:59

    Thanks K – still not working … I guess I’ve got some stubborn code somewhere:

    http://truenewzealand.com/ourtrips

    CSS: http://tinyurl.com/y96gk7x
    Custom functions pasted into .txt: http://tinyurl.com/yagkyjo

  35. kristarella says

    6 April 2010 at 11:07

    Suzi — There was a bunch of old or conflicting CSS in the file. I have made a copy of your CSS file where I’ve deleted anything not in use and made some notes up the top for things that you should enter into the options (it is better to do as much in the options as possible and only override with CSS when necessary). If you want to keep the old CSS for posterity, save the CSS file as a backup and use the new cleaned up one on the site.

    The changes I’ve made to the nav menu should get you most of the way to where you want to go. It’s really a matter of messing around in firebug until you find the right thing.

    The javascript at the bottom of your functions file is no longer necessary, it’s not currently doing anything anyway.

    You might need some CSS to clear the page title etc of the menu, not sure how you might want to do that.

  36. Suzi Piker says

    6 April 2010 at 23:39

    Thank you Kristarella — I can’t wait to give this a go and Firebug away! I hope you got my donation last week — I really appreciate this site.

  37. kristarella says

    7 April 2010 at 11:25

    Suzi — I did get it. Thanks!

  38. Russell Fisher says

    1 July 2010 at 09:38

    Kristarella, Is there any way to take what the tutorial above and make sub-menus pop out to the right? I have a vertical menu in the right sidebar and the sub-menus pop out down over the other menu items which looks bad. Your post is the closest on the web I have found to changing this. Any help would be greatly appreciated. Not super experienced with code as am fairly new to Thesis and web coding as well.

  39. kristarella says

    1 July 2010 at 11:20

    Russell — I think you can with the CSS in the comment on my other nav post. You essentially just need to change the absolute position of the dropdown.

  40. Greg Tomlinson says

    30 November 2010 at 14:06

    Kristarella,
    What a great resource you have provided here. I am most appreciative of your talents and willingness to share information.
    I have a question please. I am running Thesis 1.7. and was watching a video on using hooks. This video’s example was with Thesis 1.6, and the author of the video said to first change permissions of the custom functions PHP file to a value of 777 within the WP install on the host side BEFORE before editing the custom functions PHP on the WP admin side.
    Two questions please.
    1 Is changing permissions also required in Thesis 1.7, or is that old school?
    2. Where in the world is that file on the host side of a 1.7 install. I simply cannot find it anywhere!

    Your help would be greatly appreciated.
    Greg T

  41. kristarella says

    1 December 2010 at 17:02

    Greg — I’m not sure if changing the permissions of that file is necessary; I’d say you only need to go out of your way to change it if you can’t edit the file from the Thesis Custom File Editor. It’s located at /wp-content/themes/thesis_17/custom/custom_functions.php in the root folder of your WordPress installation.

  42. Greg Tomlinson says

    1 December 2010 at 17:55

    Thanks,
    It just spooked me a bit. Turns out I was able to do the “edit” without worrying about permissions. I uploaded and am now displaying this new header I created for our 3 week old site. http://www.coloradonewhomespecialists.com/
    For being so new to this I think it looks OK. Will continue to tweak more, however.
    Turns out that making the header look right was way harder than getting Thesis to display it. I’m liking this “little blogging engine that could.”

    Next, Dropdowns.

    Thanks Again,
    Greg

  43. keshav says

    12 December 2011 at 21:01

    my god………

    yor posts are more killer than this theme 😀 😀

  44. Mariano says

    8 March 2012 at 00:40

    Hi Kristarella! Thank you a lot for posting tutorials and snippets like this.
    I have a problem that I couldn’t solve. I want to apply the drop-up to a custom menu I wish placed in one of the sidebars.
    I really try to do that but without any success. Any advice on this? How can I do that?
    Once again, thanks!

  45. kristarella says

    19 March 2012 at 17:53

    Mariano — I would recommend having menus in the sidebar pop-out sideways, rather than up or down. To start off with I would create your menu in the WordPress menu dashboard and then add it to the sidebar with the WordPress menu widget. If you’ve added submenu items in that menu they should atuomatically dropdown (all that CSS is already in Thesis), then you would just need to use CSS positioning to move the menu to the side… something like:

    .custom .sidebar .menu li {position:relative;}
    .custom .sidebar .menu li ul {position:absolute; right:1px; top:0;}
A triptych of baubles. These are very satisfying t A triptych of baubles. These are very satisfying to paint ❤️💚💙

#watercolor #watercolour #christmas
I have really enjoyed this Christmassy painting! S I have really enjoyed this Christmassy painting! So glad my friend asked me to make some cards for our church helpers, because it set me on a roll!
#watercolor #watercolour #christmas #christmascards #watercolorcards
Had a great Saturday at the GKR Karate State Title Had a great Saturday at the GKR Karate State Titles! I was a sub for @jamesxuereb.me in the Blue Flame Dragons thanks to his sprained ankle; we won first round and came fourth overall!
I did a bunch of judging and officiating, which was really good.
I didn’t place in my individual events, but had a very fun final round of kumite (sparring).

#gkrkarate #karate
More stamping tonight. Even better than last night More stamping tonight. Even better than last night’s!
Did some stamping this evening. Love it! I wish I’d done some pages in other ink colours before I dismantled the stamps 😂
Had an appointment in the city, so I got to visit Had an appointment in the city, so I got to visit the @legocertifiedstores_anz Wicked display!
#wicked #lego #afol #sydney
A little book I made from Bunnings paint sample ca A little book I made from Bunnings paint sample cards. It’s going to be for mini paintings and collages. Sometimes it’s nice to start with a colour rather than a blank white page!
A little while ago I did some swatching of Daniel A little while ago I did some swatching of Daniel Smith and Schminke Horodam watercolours. So soothing! I love some of the granulating colours!
#watercolours
Follow on Instagram

Footer

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Top Posts & Pages

  • Sistaco Nail Powder Review
    Sistaco Nail Powder Review
  • Boobs & Dinks - early cancer detection
    Boobs & Dinks - early cancer detection
  • Home
    Home
  • Edit EPS files in Inkscape on Mac
    Edit EPS files in Inkscape on Mac
  • Exifography
    Exifography

Follow Me On…

  • Instagram
  • X
  • GitHub
  • LinkedIn
  • YouTube

Categories

Copyright © 2025 · Kristen Symonds · kristarella.com

%d