I’m returning a custom hierarchal taxonomy via wp_get_object_terms.

The trouble is that the results are being ordered by name or count, neither of which are proving reliable. (I’m using a custom taxonomy for “Location” – City, State, Country – sometimes the State appears before the City)

Is there a way I can order the resulting array by the custom taxonomy hierarchy?

Is there, perhaps, another way I should be looking at this?

2 Answers
2

Just a rough sketch to get your idea:

  • countries (hierarchical taxonomy)
    • France (country – sub taxonomy)
      • Champagne (state – sub sub taxonomy)
        • Le Mans (city – term)
        • Angers (city – term)
        • Nantes (city – term)

And you want to order:

$query_results = query( 'country' => 'france', 'orderby' => 'state city', 'order' => 'ASC' );

Did i get this right? If not, feel free to edit my answer or update your Q.

Leave a Reply

Your email address will not be published. Required fields are marked *