Support » Fixing WordPress » Trying to get an excluded category to appear in a second loop

  • Hi, I’m working on a redesign where I want to exclude two categories from the main feed. After searching forum, I found the category visibility plugin (here: which worked flawlessly to exclude the categories from the front page.

    My problem is I want a second loop in my sidebar to display entries from one of those excluded categories but when selected, it’s excluded from the entire front page including in that second spot.

    I tried reading the forums to see if someone else had posed the same question, which I’m sure they did in one way or another, but I’m not well versed in coding and reading/understaing that code (I thought I took the easy way out by using a template!). So I apologize if this has already been covered a number of times before.

    Here is my website WITHOUT the categories excluded so that you can see where I want the second loop to display:

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi, this thread will tell you how, and solve a problem you don’t even realise you’ve got, yet.

    If you scroll down, you’ll get an example of the loop, but read the thread regardless, as it’ll come in handy if your sidebar is going to be visible on Pages and Single posts.

    You are a life saver. Or at least a site saver. Worked like a charm!


    cheers 🙂

    Ok was almost ready to go live with the site and, while everything looked great and functioned up front I realized that the exclude categories plugin I was using created an error message if I tried to click on a single entry.

    I tested it on two of my sites, so it definitely was the plugin. As soon as I uninstalled it, the website functioned perfectly again.

    But as for excluding categories, I’m sort of back to the drawing board.

    I read and tried this:

    I also read and tried this:

    I can not figure this out! Clearly I was not meant for coding.

    Should I be working on the index.php page or the page.php page? I’m just confused because both seem to have a loop on them ….

    yeah, the loop is on most theme pages, and is used to display posts, regardless of how many there are.

    IMO the best way to exclude categories on the main page is to begin your loop in index.php as follows:

      if (is_home()) query_posts("cat=-66,-67");
      while (have_posts()) : the_post();

    note the negative category numbers.

    It’s easy, and requires no plugins… and also respects your max post count for the main page, unlike other methods.

    Good luck 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Trying to get an excluded category to appear in a second loop’ is closed to new replies.