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

Here describes get_posts() function. I would like to know what types of order can I pass to get_posts?

in WP admin, I can see menu order, title, date, random and ...

share|improve this question
up vote 3 down vote accepted

Refer to the WP_Query() docs for order and orderby:

order (string) - Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'.

  • 'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
  • 'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).

orderby (string) - Sort retrieved posts by parameter. Defaults to 'date'.

  • 'none' - No order (available with Version 2.8).
  • 'ID' - Order by post id. Note the captialization.
  • 'author' - Order by author.
  • 'title' - Order by title.
  • 'date' - Order by date.
  • 'modified' - Order by last modified date.
  • 'parent' - Order by post/page parent id.
  • 'rand' - Random order.
  • 'comment_count' - Order by number of comments (available with Version 2.9).
  • 'menu_order' - Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct 'menu_order' values (they all default to 0).
  • 'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
  • 'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also note that a 'meta_key=keyname' must also be present in the query. This value allows for numerical sorting as noted above in 'meta_value'.
share|improve this answer
So getting image which I click "Use as featured image" for it, is not related to query order? – Mohammad Ali Akbari Aug 21 '12 at 19:08
If you're trying to query the featured image, can you please update your original question with that information? – Chip Bennett Aug 21 '12 at 19:09

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.