I have a custom post type “building”, another called “architects” and a custom taxonomy “date” associated to buildings. The taxonomy basically is the year in which the building was finished and buildings and architects are related to one another in the sense that architects make the buildings.
What I want to achieve is run a wp_query
that will get all the buildings by a certain architect and sort them by date.
I have achieved the first part were I get all buildings by a certain architect but I cant figure out how to sort them by a custom taxonomy. I’ve read Otto’s answer here Using wp_query is it possible to orderby taxonomy? on how sorting by taxonomy doesn’t make sense, but I believe in my case it does.
This is the code I’m using to get all buildings by a certain architect.
$buildings = new WP_Query(array(
'post_type' => 'building',
'posts_per_page' => -1,
'suppress_filters' => 0,
'meta_query' => array(
array(
'key' => 'architect',
'value' => '"'.$architect_id.'"',
'compare' => 'LIKE'
)
),
'post_status' => 'publish'
));