How to Exclude a Category from the WordPress Loop

Wordpress How-To's

Here’s the question that was asked:

“Basically I want to take all of the posts in the “Freelance” category and remove them from the main content so that I can link to them from a page instead of including them in the Loop. “

Here is the code to exclude an entire category from appearing within the WordPress loop:

{code type=php}

Sorry, no posts matched your criteria.
{/code}

Basically, what you’re doing with the above code is telling the loop that if it’s in category 3, just remove it from the query that the loop is using.

Hopefully you’ve found this quick tutorial valuable. Contact me if you have any questions or would do it a different way. There’s 1,001 ways to do everything – that’s why I love coding.

Leave a Reply

Your email address will not be published. Required fields are marked *

What's the Buzz?

In working with Andy, I was extremely impressed by his overall expertise and the “can-do” attitude with which he approached every phase of the project. While some designers may have become frustrated by working with multiple decision makers with limited web development knowledge, Andy was very understanding and strategic in his approach to finding very organized solutions to address our needs. I would highly recommend him!

- Allison Davies
Ten United