Posted on 28 November, 2008 By Kim Woodbridge 29 Comments

How to Exclude a Category From the Sidebar List in WordPress

Excluded (by felinebird)

My portfolio page is created using posts and is not a static page like the About page. I did this to easily add and remove entries and so that the page didn’t become too large. It will display a set number of entries like any other blog post page.

The portfolio entries are in the category, portfolio. The code on the portfolio is set to only display that category.

I also use the Ultimate Category Excluder plugin so that the category does not display in my archives or in my rss feed. I’m hoping to spend some time on code based solution for that as well.

I realized that the Portfolio category was still showing up in the list of categories in the sidebar. I was using the Category Widget, because it’s easy, even though I’m not a big fan of widgets. The only way I could determine to exclude the category from the widget was by editing wp-includes/widget.php. For a brief moment that seemed like a really good idea. But every time I upgrade WordPress I would overwrite that file or I would have to save and redo my edits. So, not such a great idea after all.

Instead I used the list categories function and excluded the category that I didn’t want displayed. Here’s what I did:

  1. In Manage > Categories I hovered over the name of the category and got the id number that I wanted to exclude in the browser status bar. In this instance the number is 276.

    http://www.kimwoodbridge.com/wp-admin/categories.php?action=edit&cat_ID=276

  2. In Design > Widgets I removed the Category Widget and added a Text one.
  3. In the new text widget, I gave it the title Categories and added the following code:
      <?php wp_list_categories('orderby=name&exclude=276&title_li='); ?>
      
  4. If you want to exclude multiple categories, put a comma between each ID number.
  5. If you don’t have a widgetized sidebar, you can add the code to your sidebar where your current archive code is located.

That’s all there is to it. I don’t know why it took me so long to notice it was in the list. I also don’t know why I was being a dunce about the solution; it’s very similar to excluding a page from the navigation bar.

Useful? Do you have a need for this? Do you think you will use it?

photo credit: felinebird


Related Posts:
  • Using Thumbnails for Excerpts Plugin with Query Posts to Make a Custom Sidebar Block in WordPress
  • WordPress How To: 5 Tips and Tricks
  • WordPress - How to List Recent Posts from One Category
  • Random WordPress Quotes Without A Plugin
  • How to Conditionally Display WordPress Sidebar Content with is_page
  • Posted In : WordPress Tips
    If you enjoyed this post, please subscribe to my RSS Feed

    [Post to Twitter]   [Post to Delicious]   [Post to StumbleUpon]

    29 Responses to “How to Exclude a Category From the Sidebar List in WordPress”

    Leave a Comment
    You may use: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .


    Additional comments powered by BackType

    Recent Comments

      • Fábio N Sarmento: Do you have any idea how can i exclude a certain category, when the TT do the "new blog post" update, i want it show al...
      • Kikolani: Those are some good, patriotic themes that could be modified to work year round. Thanks for the round up! ~ Kristi...
      • Jannie Funster: Kim, that is just the sweetest shout-out ever. I guess no good deed with you goes unappreciaated, and in such a public ...
      • Kim Woodbridge: Hi - Is this for a fan page or a profile page? On a fan page go to Edit Page. In the list of Applications click on the ...
      • Kim Woodbridge: Hi Valerie - Sometimes when I'm really tired I just sit here and mindlessly click around the internet and the same thing...
      • Kim Woodbridge: Hi Patricia, Thank you so much for the kind words - I really appreciate it and you comment has made my day :-) Hav...
      • Kim Woodbridge: Hi John - Jeff is wonderful and a really nice person. They already have some great stuff on the new site and I can't wa...
      • Kim Woodbridge: Hi Siel - It's mostly fun - but people are difficult sometimes just like in a real job. I'm much more relaxed, which is...