Thesis theme – How to add another menu

by Larry on March 13, 2009

I recently wrapped up the development of a new theme for Cash Money Life based on the Thesis theme.  One of the requirements was to have a primary menu at the top, and a secondary menu below the title.  The primary menu would contain page links, while the secondary menu would contain categories, page links, etc.  Here’s screen shot of what we ended up implementing:

cml-header

This was the first time I had tried to add another menu with Thesis.  The trend of having two menus is becoming pretty prevalent in the blogging world, so I thought I would share a little “inside info” info on how to add another menu using the Thesis theme.  The menu I’ll add is a simple menu with very basic styling.  Of course depending on your knowledge of CSS, the possibilities are endless on how the menu could look.

Adding the menu

To add the new menu, we’ll add a new custom function and hook;  The code looks as follows:

/* Add the top navigation menu */
/* Links for top menu will need to be manually added here, since this menu isn't supported by Thesis */
function topnav_menu() {
?>
<ul id="topnav">
<li><a href="http://www.cashmoneylife.com">Home</a></li>
<li><a href="http://www.cashmoneylife.com/about">About</a></li>
<li><a href="http://www.cashmoneylife.com/archives">Archives</a></li>
<li><a href="http://www.cashmoneylife.com/about">Contact</a></li>
</ul>
<?php
}
add_action('thesis_hook_before_header', 'topnav_menu');

This code should be copied and pasted into your custom_functions.php file. There are multiple ways to edit your custom_functions.php file. I prefer to just ftp to my server using the FireFTP Firefox Addon and edit the file using a text editor (I use Notepad++). You can just add the code at the bottom of the file and save it.

You’ll now have a “menu” displayed at the top of your blog, but it will be pretty ugly, since we haven’t styled it.

Styling your menu

Now that we have the code and hook functioning correctly, let’s make it look nice. As I mentioned earlier, I’m just going to use a very simple style. Gray background, black text, and left justified (the menu on Cash Money Life is right justified).

Here’s the CSS:
/* Top Nav bar */
.custom ul#topnav {
border-style: none;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
background:#E4E4E4 none repeat scroll 0 0;
width: 100%;
float: left;
}
.custom ul#topnav li { float: right; padding: 3px 10px 3px 0px; }
.custom ul#topnav li a { font-size: 1.1em; color: #000000; }
.custom ul#topnav li a:hover { text-decoration: underline; }

I won't go into the gory details on how the CSS styling actually works, but suffice it to say it styles our "topnav" menu with a gray background (#E4E4E4), makes the menu go across the whole width of the screen (width: 100%), and makes the link colors black (#000000).

The above CSS code should be copied and pasted into your custom.css file. Where you paste it doesn't really matter, although I prefer to organize my CSS files in same order as the HTML.  So this would go at the top.  Save the file and reload your website and you show now have a nicely formatted menu at the top of your blog!

How you use this menu is really up to you, but a common use is to use the top menu for page links such as "Home", "About", "Contact", etc.  The secondary menu, or Thesis default menu, is then used to link to category pages.

{ 13 trackbacks }

links for 2009-04-21 | girliegeek
April 21, 2009 at 3:03 am
8 Thesis Theme Tutorials You Can Use Today
April 27, 2009 at 6:55 pm
100 Resources for Thesis Wordpress Theme Users | MattFlies.com
May 20, 2009 at 4:54 pm
[GET]Great Resources for WordPress Thesis Theme Users - 2790th Edition | marketFly
June 9, 2009 at 5:22 am
100 Tài nguyên hữu ích cho người sử dụng Wordpress Thesis Theme | GIẢI PHÁP SỐ
July 6, 2009 at 2:15 am
100 resources for users of the excellent Thesis Theme for Wordpress
August 5, 2009 at 11:47 am
Mini-Tips, Facebook Connect, a Contest and More Answers! | 3asslema4Host
August 13, 2009 at 8:06 am
60 Wonderful And Helpful Thesis Theme Customization Tutorials
September 13, 2009 at 9:22 am
60 Wonderful And Helpful Thesis Customization Tutorials - Cash-Bandit.com
September 13, 2009 at 10:06 am
100 Tài nguyên hữu ích cho người sử dụng Wordpress Thesis Theme | TinhYeu.Mobi
September 26, 2009 at 9:19 pm
links for 2009-09-29
September 29, 2009 at 7:37 pm
250+ Thesis Theme Resources | Sahil Kotak dot Com
December 8, 2009 at 3:28 pm
MattFlies: 100 resources for Thesis Theme users : WordPress Blue
December 20, 2009 at 11:29 am

{ 24 comments… read them below or add one }

Patrick March 16, 2009 at 4:41 pm

Love the job you did on my site, Larry! But now everyone is going to have the same upper nav bar! ;)

Jeff Rose March 16, 2009 at 4:47 pm

Larry-

Thanks for the info. I attempted this on my own a bit ago and had no luck, so this is great. And don’t listen to Patrick, I don’t see anybody else using your tips *cough* http://www.jeffrosefinancial.com. Ehh-hem, I mean thanks again! :)

Ray March 28, 2009 at 3:50 am

Hi Larry,

Using Thesis myself and came across your site via the Thesis Support Forum.

Your post on adding a top nav menu was very helpful and I thank you for you for posting it.

Regards,

Ray

Althaf April 29, 2009 at 5:19 am

Hey,

It did not work for me. You can check my site in the title. Just doesn’t work.

Larry April 29, 2009 at 7:07 am

Althaf, I don’t see any of the code in my article on your site.

Althaf April 29, 2009 at 7:40 am

I removed it to be honest. I did exactly as you asked. Twice. Pasted it on top and bottom. Yet, nothing. Any advice?

fanari May 4, 2009 at 12:57 pm

You should write all the codes in HTML entities

Larry May 4, 2009 at 9:28 pm

Hi fanari. Not sure I understand what you mean.

Benjamin Ficker May 8, 2009 at 12:42 am

Hey Larry,
Thanks for the tutorial. I tweaked your process a little, I added the 2nd menu to below the header. I just changed the hook. My problem is in styling the menu. I am trying to get it to look like the default menu with thesis. I tried copying the nav menu styles from the style.css and changing the #tabs to #topnav. That got it lined up right, but I can not get the links to be in their own little box and spaced correctly. ANy help would be great.

Larry May 8, 2009 at 5:22 am

Benjamin, there’s a trick. There is also some styling in layout.css. This is the file Thesis uses when you change the font settings in the Thesis Design screen. You’re missing two additional styles for the anchor:

ul#topnav li a {
color:#111111;
display:block;
letter-spacing:2px;
line-height:1em;
text-transform:uppercase;
font-size:1.1em;
padding:0.545em 0.818em;
}

The one’s your missing are the last two for font-size and padding.

Benjamin Ficker May 8, 2009 at 5:37 am

That did the trick. Thanks so much for your help. I really appreciate it.

Chris May 13, 2009 at 12:19 am

rockin’ dude. thanks for the tip!

nino May 13, 2009 at 8:28 am

Hi Larry

I added the code but it’s displaying below of the thesis menu
Any idea?

thanks

Mary McRae May 31, 2009 at 6:36 pm

Thanks for the info! I’ve created a custom nav in the header and it’s almost perfect. I have tweaked the main nav to change background/font colors when the page is active; any way to get similar behavior in the custom nav bar?

vb July 25, 2009 at 12:15 pm

Thanks for the tutorial. Works perfectly. I want to have the date in the same navbar to the left. How could I accomplish having your navbar code to the right navbar and a date in the left side of your navbar?

Larry July 25, 2009 at 8:49 pm

Thanks vb. Just float the date “left”, and float the other li items “right”. That should do it.

Get paid to work online July 26, 2009 at 10:46 am

I added the code but it’s displaying below the menu any one out here has any solution for the same

Bob32 October 22, 2009 at 1:34 pm

Many of you may have already heard, but the favored replacement for Chairman is David Buskill. ,

Tinh October 29, 2009 at 9:54 pm

It is nice one indeed, let’s try it now and see how it works with my new blog. Thanks

Arnold Hight November 19, 2009 at 1:05 pm

Thanks, great simple easy code to start with and customize for your own site. Much appreciated!

Senthil Ramesh November 29, 2009 at 9:25 am

Can this display the links with drop down menu. I guess not. Can you give the code how to display sub pages with drop down menus.

Abu Mustafa December 31, 2009 at 2:17 pm

Your tips are spot on. I made a small change to allow for adding new links using the Link Manager from Wordpress.


/* Add the top navigation menu */
/* Links for top menu will need to be manually added here, since this menu isn't supported by Thesis */
function topnav_menu() {
?>

<?php wp_list_bookmarks( 'title_li=&categorize=0&category=3&before=&after=&show_description=0&orderby=url' ); ?>

<?php
}

Abu Mustafa December 31, 2009 at 2:19 pm

Sorry, formatting problems with first post…

Your tips are spot on. I made a small change to allow for adding new links using the Link Manager from Wordpress.

/* Add the top navigation menu */
/* Links for top menu will need to be manually added here, since this menu isn’t supported by Thesis */
function topnav_menu() {
?>

<?php wp_list_bookmarks( 'title_li=&categorize=0&category=3&before=&after=&show_description=0&orderby=url’ ); ?>

<?php
}

Holly January 12, 2010 at 8:05 pm

This is just what I was looking for, but I was also wondering if it was possible to create drop down menus for the category bar? It seems that even if my categories have parents, they all show in the bar. Thanks!

Leave a Comment

Previous post:

Next post: