jeudi 5 mars 2015

How to order by multiple fields using standard query_posts?


In our archive.php we show all the items which match our selected category. This works absolutely fine.


Then we improved it by adding (just before the loop) a sort and upping the posts per page from the default 10, like so:



$posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=99');


This works even better.


Now, however we want to sort by more than one field, say menu_order then title. I don't see a way to do this using this query_posts / querystring syntax we have in place. Code samples all involve firing up a new WP_Query, losing track of the query_string. What's the solution?





Aucun commentaire:

Enregistrer un commentaire