WordPress Navigation Bar

Filed in: WordPress — May 7th, 2005

Many have asking me about how to add the top navigation bar to the WordPress like my blog. I was doing it manually by adding CSS and HTML code. To make it easier for general bloggers, I made the following WordPress Navigation Bar hack.

wordpress navigation bar

What it does?

Add a navigation bar under template header image. The navigation bar has a tab that link to blog URL and auto add WordPress ‘pages’ link tabs.

How to apply?

There are two ways to apply:

  1. Copy and paste the WordPress Navigation Bar code to the end of /wp-content/themes/default/header.php.
  2. OR, Easier method. Download the modified header.php, extract it to /wp-content/themes/default/ (replace existing header.php file).

Credits:

Note: This hack is designed for WordPress default theme(kubrick) only. However, you may modify it as you want.

FAQ

  1. How do adjust the position of the navigation bar?
    Simply modify the values of “top” and “left” under “#supernav”.
  2. How to list Pages by menu order?
    Find:
    <?php wp_list_pages('title_li='); ?>
    then, replace it with:
    <?php wp_list_pages('sort_column=menu_order&title_li='); ?>
    More details are available at WordPress Codex/wp list pages.
  3. How do I add custom URL into the navigation bar?
    Sorry, you can’t. The hack code only creates tabs based on your WordPress Pages.

Like this post? Please share:

Follow @liewcf on Twitter; Join Facebook page; Subscribe to free newsletter for updates like this article..

  • http://deepdesign.biz/ James

    also how would I go about changing the font/size of the text in the tabs?
    Thanks
    J

  • http://deepdesign.biz James

    also how would I go about changing the font/size of the text in the tabs?
    Thanks
    J

  • http://deepdesign.biz/ James

    one final question – I notice that when this navigation bar is running that the grey panel on the right dissapears on all the static pages, and is only visiible on the blog homepage. Is this a known issue?

  • http://deepdesign.biz James

    one final question – I notice that when this navigation bar is running that the grey panel on the right dissapears on all the static pages, and is only visiible on the blog homepage. Is this a known issue?

  • http://www.pudweb.com/ Pud

    For people using the default (kubrick) header I use -20px and “relative” and it seems to work fine for me (www.pudweb.com). i.e.

    #supernav {
    font: bold 9px/9px Verdana, Lucida Grande, Arial, Helvetica, Sans-Serif;
    position: relative;
    top: -20px;
    left: 50%;
    width: 720px;
    margin: 0 0 0 -360px;
    padding: 5px 16px; /* duplicate the tab size */
    text-align: left;
    display: block;
    }

    I have also tweaked the PHP highlighting code so that it works (a little better) with the WPG2 (WordPress Gallery2) plugin by changing header.php

    <div>
    <ul id="supernav">
    <li class="<?php if (( (is_home() ) && !(is_paged()) && !(strstr($_SERVER['PHP_SELF'], ' wp-gallery2.php'))) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="<?php echo get_settings('home'); ?>">blog</a></li>
    <?php wp_list_pages('sort_column=menu_order&title_li='); ?>
    </ul>
    </div>

  • http://www.pudweb.com Pud

    For people using the default (kubrick) header I use -20px and “relative” and it seems to work fine for me (www.pudweb.com). i.e.

    #supernav {
    font: bold 9px/9px Verdana, Lucida Grande, Arial, Helvetica, Sans-Serif;
    position: relative;
    top: -20px;
    left: 50%;
    width: 720px;
    margin: 0 0 0 -360px;
    padding: 5px 16px; /* duplicate the tab size */
    text-align: left;
    display: block;
    }

    I have also tweaked the PHP highlighting code so that it works (a little better) with the WPG2 (WordPress Gallery2) plugin by changing header.php

    <div>
    <ul id="supernav">
    <li class="<?php if (( (is_home() ) && !(is_paged()) && !(strstr($_SERVER['PHP_SELF'], ' wp-gallery2.php'))) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="<?php echo get_settings('home'); ?>">blog</a></li>
    <?php wp_list_pages('sort_column=menu_order&title_li='); ?>
    </ul>
    </div>

  • http://wi01b.net/ boris

    Any chance to get this running with subpages enabled? Using depth=1 will totally f*ck up the menu… :(

  • http://wi01b.net boris

    Any chance to get this running with subpages enabled? Using depth=1 will totally f*ck up the menu… :(

  • http://Blog.mynetcity.com/ John Wong

    It was awesome, a big thanks for you!!!
    After nights of constraction, its work perfectly now…

    Again, Thanks for your contributions!

  • http://Blog.mynetcity.com John Wong

    It was awesome, a big thanks for you!!!
    After nights of constraction, its work perfectly now…

    Again, Thanks for your contributions!

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    This is a awesome hack.
    I tried it but I wanted it shifted to the right instead of the left but it’s not working correctly.
    I know nothing about .php. Would someone help me with this?

    http://www.thepodcastreview.com/

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    This is a awesome hack.
    I tried it but I wanted it shifted to the right instead of the left but it’s not working correctly.
    I know nothing about .php. Would someone help me with this?

    http://www.thepodcastreview.com/

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    It’s gotten worse.
    It looks fine now in Firefox on my Mac but it is way off in Internet Explorer on Windows.
    And, for some reason, I now have a a line through my blog title in Firefox but not in Internet Explorer.
    I’m freaking out!

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    It’s gotten worse.
    It looks fine now in Firefox on my Mac but it is way off in Internet Explorer on Windows.
    And, for some reason, I now have a a line through my blog title in Firefox but not in Internet Explorer.
    I’m freaking out!

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    UPDATE:
    Ok, it looks fine now in Firefox on my Mac but it’s still screwed up in IE on Windows.
    HELP!

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    UPDATE:
    Ok, it looks fine now in Firefox on my Mac but it’s still screwed up in IE on Windows.
    HELP!

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    UPDATE again:
    it’s not browser specific nor OS specific, it’s resolution specific.
    I am view the site on different computer with different resolutions, it’s not standard.
    Is there a way to fix this so that it is standard no matter what resolution you view it?

  • http://www.thepodcastreview.com/ EdTheUniqueGeek

    UPDATE again:
    it’s not browser specific nor OS specific, it’s resolution specific.
    I am view the site on different computer with different resolutions, it’s not standard.
    Is there a way to fix this so that it is standard no matter what resolution you view it?

  • http://www.thepolishambassador.com/ Dave

    Hi Liew, I’m using your plugin and it works great. Im trying to incorporate a wordpress store plugin, but when i do it creates extra pages in the header. Now, i realize that is the problem of the other plugin not yours, but is there a way to make pages that do not display in the nav bar. i think that would help things out a bit.

  • http://www.thepolishambassador.com Dave

    Hi Liew, I’m using your plugin and it works great. Im trying to incorporate a wordpress store plugin, but when i do it creates extra pages in the header. Now, i realize that is the problem of the other plugin not yours, but is there a way to make pages that do not display in the nav bar. i think that would help things out a bit.

  • Pingback: Flyweb »» blog site » Blog Archive » Kubrick and WordPress

  • http://www.hintons.info/ Ben

    Liew! Your code rocks as usual. Simple, purposeful! Thanks! B

  • http://www.hintons.info Ben

    Liew! Your code rocks as usual. Simple, purposeful! Thanks! B

  • http://www.flyweb.nl/ Martin

    Liew, actually you can put an url in your navbar yourself. Pick one you like and code like this:
    ">/wordpress/wp-content/plugins/falbum/wp/album.php">photos
    You see? Easy like cake…
    Liew can you help me with something else about the navbar? It looks like the ‘hack’ bit in the CSS shoves my theme a bit around. I see a 2 pixel high white stripe at the bottom of the footer. Why I wonder?

  • http://www.flyweb.nl Martin

    Liew, actually you can put an url in your navbar yourself. Pick one you like and code like this:
    ">/wordpress/wp-content/plugins/falbum/wp/album.php">photos
    You see? Easy like cake…
    Liew can you help me with something else about the navbar? It looks like the ‘hack’ bit in the CSS shoves my theme a bit around. I see a 2 pixel high white stripe at the bottom of the footer. Why I wonder?

  • http://www.lucasmcdonnell.com/ Lucas McDonnell

    Martin,

    If you change the ’2px’ below to ’0px’, that white stripe will no longer show up. I had the same issue on my site.

    #hack {
    background: white;
    height: 2px;

  • http://www.lucasmcdonnell.com Lucas McDonnell

    Martin,

    If you change the ’2px’ below to ’0px’, that white stripe will no longer show up. I had the same issue on my site.

    #hack {
    background: white;
    height: 2px;

  • Pingback: The Philpot Spot » Blog Archive » Genesis, the snide version

  • Pingback: 随锅逐流 » Extended Live Archive 0.10 版本教學

  • Pingback: 滚瓜壮格 » Ultimate Tag Warrior 教學

  • http://www.angkordesign.net/ Sim Kamsan

    Hi it simple but great tutorial. thanks.

  • http://www.angkordesign.net/ Sim Kamsan

    Hi it simple but great tutorial. thanks.

  • http://www.play-bingo-uk.co.uk/ Play UK Bingo

    I always mess things up when I try to hack my wordpress. I’ll give this a try…thanks a lot for the tute

  • http://www.play-bingo-uk.co.uk Play UK Bingo

    I always mess things up when I try to hack my wordpress. I’ll give this a try…thanks a lot for the tute

  • Pingback: 5个Wordpress导航菜单教程 | 帕兰映像

t