Seattle and Tacoma WordPress Design and WordPress Development

Excluding categories in the sub-navigation bar

Just a quick tip this AM.

If you have a theme that has a sub-navigation bar for categories, often they have a theme setting on which categories you can include or not in the bar. But if they don’t, here is a few steps to ensure certain one’s won’t appear…

First, you need to find out the number ID for each category you want to exclude. An easy way of doing this it to go to your category list page under “posts”, then run your cursor over the page to identify the number. Look at the bottom of your browser page and you will see a url with the number at the end.

Now go into your appearance menu, and choose the editor. On the left hand find your file “header (header.php) and open it.

Look for this code:

<?php wp_list_categories(‘orderby=name&title_li=&depth=2′); ?>

Replace it with this

<?php wp_list_categories(‘orderby=name&title_li=&depth=2&exclude=1,2,3‘); ?>

or you can use this to select only the categories you want to appear

<?php wp_list_categories(‘orderby=name&title_li=&depth=2&include=1,2,3‘); ?>

Just remember, if you aren’t comfortable with coding, make sure you have everything exact, no extra spaces and no “,” after the last category number. To be safe, copy the whole files text into a text window as a backup. Good luck!

Comments

One Response to “Excluding categories in the sub-navigation bar”
  1. Alison says:

    Thank you catseyemarketing – was tweaking a StudioPress theme this morning, scratching my head, and your code worked first time – you made made my day :-)
    There are so many situations where it’s handy to hide a category.

Share Your Thoughts

Tell us what you think about this post...
and oh, if you want a pic to show with your comment, go get a gravatar!

Seattle and Tacoma WordPress Design and WordPress Development