Tammy Hart Designs

How to Use Categories as Your Navigation Bar

I wrote a post a few months back that discusses >how to use pages in a horizontal navigation bar. It’s a pretty standard thing to see a horizontal navigation, but a lot of blogs that don’t pull as much focus to their static pages are using their categories as their main navigation. If you’re wanting to do this in a horizontal style, a good example is right above you on my own blog, where I use them as a secondary navigation.

You can pretty much follow all of the steps outlined in my previous article, except rather than using wp_list_pages, you’ll want to use wp_list_categories like so:

<ul id="nav">
wp_list_categories('title_li=');
</ul>

As usual, make sure that you leave that title_li= in there without a value so that the code is rendered semantically.

The only problem you may run into is if you use child categories. This can be fixed by using a dropdown method such as Suckerfish. Changing the depth of the list that WordPress delivers is the same with categories as it is with pages, so adding the variable depth=1 will eliminate the need for dropdowns since all you’ll get is the parent categories.

One Response to “How to Use Categories as Your Navigation Bar”

  1. Lily  

    Thanks Tammy, I just used your code to make a horizontal categories bar for navigation at the top of my blog (under construction). Thanks!

Leave a Reply