Title: Ordering posts
Last modified: August 18, 2016

---

# Ordering posts

 *  [Rub3X](https://wordpress.org/support/users/rub3x/)
 * (@rub3x)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/)
 * I have a cost column in wp_posts, and I need to order the posts by the highest
   number in the cost column. Where is the SQL query that lists posts – or what 
   are alternative ways.

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

 *  [Pizdin Dim](https://wordpress.org/support/users/pizdin_dim/)
 * (@pizdin_dim)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548670)
 * According to the [Codex](http://codex.wordpress.org/Alphabetizing_Posts), you
   should be able to do this:
 *  `$posts = query_posts($query_string . '&orderby=xxxx&order=desc');`
 * where “xxxx” is your custom posts column name. Put it just before “the loop”.
 *  Thread Starter [Rub3X](https://wordpress.org/support/users/rub3x/)
 * (@rub3x)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548676)
 * Sorry what’s $query_string ?
 *  Thread Starter [Rub3X](https://wordpress.org/support/users/rub3x/)
 * (@rub3x)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548679)
 * Hmm I added $posts = query_posts($query_string . ‘&orderby=cost&order=desc’);
   before the loop and there was no change ;(
 *  [Pizdin Dim](https://wordpress.org/support/users/pizdin_dim/)
 * (@pizdin_dim)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548680)
 * It works for me, read the Codex.
 *  Thread Starter [Rub3X](https://wordpress.org/support/users/rub3x/)
 * (@rub3x)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548704)
 *     ```
       $posts = query_posts($query_string . '&orderby=cost&order=desc');
       <?php if (have_posts()) : ?>
       	<?php
       while (have_posts()) : the_post(); ?>
       			<!-- post start -->
       			<div class="clearfix post">
       				<h1><?php the_title(); ?></h1>
       					<?php the_content('Site Details'); ?>
       			</div>
       			<!-- post end -->
       		<?php endwhile; ?>
       ```
   
 * That’s exactly what I have.
 *  Thread Starter [Rub3X](https://wordpress.org/support/users/rub3x/)
 * (@rub3x)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548735)
 * The SQL query it’s doing is
 * ORDER BY post_date desc
 * Obviously not the function I need.
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548742)
 * The orderby parameter only works with:
    ‘author’, ‘date’, ‘category’, ‘title’,‘
   modified’, ‘menu_order’
 * In 2.1.3, this is in the wp-includes/query.php file on line 901. If you add your
   column to this, it should allow it. Note that you’ll have trouble upgrading later
   if you’re using custom columns and core hacks and such stuff as this.
 *  Thread Starter [Rub3X](https://wordpress.org/support/users/rub3x/)
 * (@rub3x)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548802)
 * Yea I got it after my last post. Edited the cost clause in manually, and surprisingly
   WP is still functional 😀
 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548833)
 * at some point I’ll have to release my custom ordering plugin. it works off a 
   custom field, but sorta requires you always use it on all posts. Good for vertically-
   oriented uses of WP.
 *  [niklasbackman](https://wordpress.org/support/users/niklasbackman/)
 * (@niklasbackman)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548855)
 * Hi,
    Can you view/list the Posts by Custom field? The way you can reorder Pages
   by their Page Order?
 *  [parweb](https://wordpress.org/support/users/parweb/)
 * (@parweb)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548907)
 * [@rub3x](https://wordpress.org/support/users/rub3x/) have you resolv your problem
   because i would like to make same ?
 * sorry for my english
 *  [komments](https://wordpress.org/support/users/komments/)
 * (@komments)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548920)
 * A little background – I am not a programmer but I can follow directions.
 * I am using WordPress 2.0.2 and recently my posts started appearing out of order.
   When my page loads ([http://www.pcstupidity.com](http://www.pcstupidity.com))
   the oldest posts appear first. This also occurs when I go to the Manage section
   and look at my last 15 posts (it shows the first 15).
 * I did not find a query.php file so I am unsure how to fix the this. I haven’t
   found a section in the Admin pages that allows me to set sort order for posts
   nor do I know what file in the WordPress group that needs to be modified.
 * If anyone can point me at the correct file I should be able to find out where
   the Order By date descending is located.
 * I would prefer not to have to upgrade the software if at all possible.
 * TIA.

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

The topic ‘Ordering posts’ is closed to new replies.

## Tags

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

 * 12 replies
 * 7 participants
 * Last reply from: [komments](https://wordpress.org/support/users/komments/)
 * Last activity: [18 years, 3 months ago](https://wordpress.org/support/topic/ordering-posts-3/#post-548920)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
