WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have a custom taxonomy defined for "Projects" and a page that shows all the projects. In this page there's a jquery filtering menu (isotope). Initially the page must show all the projects but chronologically ('chronological' is a category and 1970, 1980, 1990, etc are subcats for a Projects element) ordered in DESC mode.

Now the query that initially shows the Projects in the page is

query_posts('post_type=portfolio&project-type='.get_post_meta($post->ID, 'portfolio_page_cats', true).'&posts_per_page=-1&orderby=menu_order&order=ASC');

There are a lot of questions about this argument, i know. Please, what is the best way to do that?


share|improve this question
Just so I'm clear, 'Projects' is a taxonomy with a slug of 'project-type', containing a term 'chronological', and 'chronological' contains sub-terms corresponding to numeric dates (and you want to sort by those sub-terms)? – Matt van Andel Feb 24 '13 at 0:44
Yes, it's correct – lucavb Feb 24 '13 at 12:09
up vote 1 down vote accepted

If you are trying to order your posts by taxonomy terms, it's not technically possible in one query (since multiple terms can belong to multiple posts - which means that WordPress cannot support 'orderby' for taxonomies or terms because there are potentially more than one).

Your solution would be:

  1. Fetch a list of your (sub)terms and loop through them.
  2. In each term loop, run query_posts() to fetch only posts attached to the current term.
  3. In each term loop (after the query), create your content-output loop to display your posts.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.