Title: query_post sorting headache!
Last modified: August 18, 2016

---

# query_post sorting headache!

 *  [threeds](https://wordpress.org/support/users/threeds/)
 * (@threeds)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/query_post-sorting-headache/)
 * Forgive my ignorance, I’m trying to achieve something quite simple in WordPress.
   I have several posts and I want to sort these post first by ascending category,
   and descending date. Something like
 * SELECT * FROM `wp_posts` order by post_category ASC, post_date DESC
 * I’ve been trying to break down the query_posts function, but I can’t seem to 
   get it to work like that. Without actually hacking the function (since I dont
   want to break any plugins that might utilise it), is there a way to order my 
   posts the way I want it? Better still, instead of using query_post in the main
   page, can I substitute it with my own SQL Code?
 * Many thanks for any help!

The topic ‘query_post sorting headache!’ is closed to new replies.

## Tags

 * [by](https://wordpress.org/support/topic-tag/by/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [threeds](https://wordpress.org/support/users/threeds/)
 * Last activity: [19 years, 9 months ago](https://wordpress.org/support/topic/query_post-sorting-headache/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
