Title: Changing Post display order?
Last modified: August 18, 2016

---

# Changing Post display order?

 *  [davidjackson](https://wordpress.org/support/users/davidjackson/)
 * (@davidjackson)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/changing-post-display-order/)
 * I would like to have the post ORDERED BY catagory(ID),post(ID) when they on displayed
   on the index page?
 * Which PHP file is the SQL statement in?
 * tia,
    david

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [skeltoac](https://wordpress.org/support/users/skeltoac/)
 * (@skeltoac)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/changing-post-display-order/#post-235173)
 * You don’t have to edit core files to accomplish this. You can customize the query
   right in your template.
 * Study [http://codex.wordpress.org/The_Loop](http://codex.wordpress.org/The_Loop)
   and wp-db.php to understand the WP_Query class.
 *  Thread Starter [davidjackson](https://wordpress.org/support/users/davidjackson/)
 * (@davidjackson)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/changing-post-display-order/#post-235199)
 * sketloac —
    Thanks for you reply, but you’ll have to excuse me a more-or-less
   just a ol’ database hacker, not a php progammer…
 * I’ve looked in template-functions-catatory.php and and it looks like catagory
   id is used as sort order, when displaying posts?
 * About line# 265:
 * if (intval($categories)==0){
    $sort_column = ‘cat_’.$sort_column;
 *  $query = “
    SELECT cat_ID, cat_name, category_nicename, category_description,
   category_parent FROM $wpdb->categories WHERE cat_ID > 0 $exclusions ORDER BY 
   $sort_column $sort_order”;
 *  $categories = $wpdb->get_results($query);
    }
 *  [Dylan Kuhn](https://wordpress.org/support/users/cyberhobo/)
 * (@cyberhobo)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/changing-post-display-order/#post-235221)
 * I should probably try it before piping up, but what if you followed the example
   here
 * [http://codex.wordpress.org/Alphabetizing_Posts](http://codex.wordpress.org/Alphabetizing_Posts)
 * but with &orderby=cat_ID,postID ?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Changing Post display order?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Dylan Kuhn](https://wordpress.org/support/users/cyberhobo/)
 * Last activity: [20 years, 11 months ago](https://wordpress.org/support/topic/changing-post-display-order/#post-235221)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
