WordPress – Exclude Categories From Main Page

At Conversatio Morum, we love WordPress. It’s the tool used for everything web related. So giving you a way to do neat things in WordPress sounds like a great idea.

This past week I preached at my church. It’ll be up on our podcast site soon. You can find it here. While preparing I had an idea. A lot of people ask for my notes after I teach in different settings. How cool would it be to have a place where people could just go and get my notes? So I created a separate ‘hidden’ part of my blog called notes. It doesn’t show on any menus and anything marked in the Notes category won’t show on the main page. I can find a lot of uses for this in developing sites for news, church, or other organizations and figured I’d show you how to exclude categories from the main page and have them post to a separate page.

Caution: you could bork your site if you are unfamiliar with WordPress. That is part of growth and becoming more awesome at it, but be aware that we aren’t responsible if that occurs.

First, the code:

  1. You need to find the category number. You do this by going to posts\categories\edit the category you need\look for the id in the web address (mine was 65)here’s a visual:
    category number
  2. In the editor portion of WordPress, select your theme in the top right corner and then browse to your index.php file.
    Editor

    1. Next insert this into index.php<?php if(is_home()) {query_posts("cat=-YOURCATEGORYIDNUMBER");}

      here’s a visual:
      exclude cat index
  3. Then you’ll need to adjust your links to posts at the bottom of the page
    1. Choose single.php from the same menu
    2. in single.php find next_post_link and previous_post_link
    3. there are 4 options for this function that you can reference here but the big idea is that you need the 4th which is the excluded category id number (read: you’ll need to put something in the other 3 to get there)
      here’s a visual:
      exclude from next-previous

Next we’ll need to make a page for the category and hide the category from any category widget you have.

First, Hiding the plugins:

  1. If you don’t have these yet, you’ll need them soon. So download them.
  2. Page Links To and Widgets Reloaded
    here’s a visual:
    PluginsNeeded
  3. Once you activate Widgets Reloaded, you’ll have to re-setup some widgets, but you’ll be surprised at the control you have over how you can set them up
  4. Next create a Notes page (or whatever other category you want)
    1. On the new page user Page Links To at the bottom to point it to the category page
      1. Categories have their own page automatically, so this isn’t necessary. However, this will give you a shorter link so you can go from http://blogname.com/category/categoryname to http://blogname.com/categoryname
    2. Here’s a  visual:
      PageLinksTo

And that’s it. Now you have a fully functional separate page for specific posts. It won’t show up on your home page and it’s hidden unless you choose to share it.

What do you think? Was this tutorial helpful? Would you appreciate more like this?