I am working on a wordpress theme and need to select posts that are in multiple categories to build a menu. I could set it up to work off of the tags, or a combination of tags and categories, but in the end I need to be able to search by multiple cat/tag. The only built-in wordpress function that I have been able to find that allows for a multiple AND search on cat/tag is the query_posts function as such:
query_posts(array('category__and' => array(list_of_cats)))
There are two problems with that. The first is that the wp docs say not to use it. The second is a real problem in that I need to know how many posts were queried before running my loop since I don't want to build submenus that are empty or only have one or two items in them.
The alternative is to run my own query but I can't quite figure out the right statement to run to find posts in the selected categories. I can visualize what needs to happen to search for two categories, but it gets fuzzy at 3+.
I can execute multiple, independent queries and then use array_intersect to find the those that match all queries but I would like to expand my mysql and/or wp knowledge a bit here.
In summary, I would appreciate an answer to any one of the following questions:
1 - an alternative to query_posts() that allows for multiple AND matching
2 - a way to find the number of posts that will be looped when using query_posts()
3 - some mysql magic that runs a big union on multiple queries to the same table
Thanks in advance