There are many times when I have created a site using WordPress where I have had trouble managing the categories I had created. I would have many different main categories, but many times the “child” or “sub-categories” would be the same. This led to category-overload as there would be tons of different categories that made managing them a nightmare.

For Example:
- Category 1
- Pictures
- Videos
- Articles
- Category 2
- Pictures
- Featured
- News
Typically that’s how I have been setting up categories. You will notice that they both contain the sub-category “Pictures.” You can imagine how long your category list can get when setting up your backend this way.
I was trying to find a solution to this because I knew that there had to be a better way and eventually came across this:
query_posts(array(‘category__and’ => array(2,6)));
What this allows you to do is only display the posts that are in two categories (in this example 2 & 6). For this to be the most effective, you will want to set up your categories in a different way than mentioned above:
- Category 1
- Videos
- Articles
- Category 2
- Featured
- News
- Pictures
Normally I would have set up “Pictures” as a subcategory under Category 1 & Category 2, however, what this allows you to do is set up a “Pictures” category only one time and apply posts to that category and the main category.
So when displaying your posts, the code says only show posts that are in “Category 1″ and “Pictures.”
Hope this helps anyone who might have had difficulty trying to figure this out. It helped save me a lot of clutter, confusion and frustration when setting up mine.

