List Hierarchical Term List with Count with Related Term

What I have are custom posts (of a custom post type, wps_business) that have two taxonomies (wps_location & wps_type), and I would like to list all the terms from type of a specific location.

For example:

Read More
  • POST 1: King’s English Cafe, location: London, type: Restaurant (parent), English
  • POST 2: La Madeline, location: Paris, type Restaurant (parent), French
  • POST 3: Uncle Julios, location: London, type: Restaurant (parent), Mexican
  • POST 4: San Marinos, location: London, type: Restaurant (parent), Italian
  • POST 5: Chipotle, location: London, type: Restaurant (parent), Mexican
  • POST 6: Olive Garden, location: London, type: Restaurant (parent), Italian
  • POST 7: Home Depot, location: London, type: Home & Garden (parent), [no-child]
  • POST 8: Lowe’s, location: London, type: Home & Garden (parent), [no-child]
  • POST 9: Frank’s Car, location: London, type: Local (parent), Mechanic
  • POST 10: Smith’s Car, location: London, type: Local (parent), Mechanic
  • POST 11: King’s Bank, location: London, type: Local (parent), Bank

..etc..

So what I would like to is have a display on the location London page is just a list of terms from type that have posts associated with location London (taxonomy: location). So…

Home & Garden (2)

Local (3)

  • Mechanic (2)
  • Bank (1)

Restaurant (5)

  • English (1)
  • Mexican (2)
  • Italian (2)

I was thinking that I needed to customize Walker_Category class; however, I believe that a more complex query may be needed. I’d rather not fetch all posts and cycle through to create this. Suggestions? Is there a SQL that will fetch these?

Related posts

Leave a Reply

1 comment