what types of order can I pass to get_posts() via orderby?

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 …

Related posts

Leave a Reply

1 comment

  1. 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’.