Quantcast
Viewing all articles
Browse latest Browse all 36

WP Query – Group by relation (custom post type)

I have a custom post type Office. An office has an address, email, … . An office also has a relation with a custom post type Region.

So an Office must have a relation with a relation with one region (Many-to-One). But how can I integrate this with my WP_Query.

I would like to show all the offices grouped by their region.

I can get all the regions and then loop through them and get the offices (WHERE region == ..). But is there a better way to do this performance wise?


Viewing all articles
Browse latest Browse all 36

Trending Articles