Interesting category counting question.
-
Hi all,
Every post on my website is in two categories. A City category and a Letting Agent category. These are the top level categories and they both have many subcategories, which are the city names and letting agent names.
Basically what I am hoping to do is query the posts from my selected city category and display the number of letting agents that are operating in this city.
I would like to do this anywhere on the website. So far I have the City category in a variable called $city.
So something like.
1. query_posts(“cat=$city”);
2. Find the Letting agent subcategories which these posts belong to.
3 Display the number of these subcategories.Note I am not trying to find the number of posts, but the number of categories. WordPress doesn’t have an inbuilt function :-(.
Thanks for your help!
- The topic ‘Interesting category counting question.’ is closed to new replies.