The WP_Query page on the Codex has a section on Order & Orderby Parameters.
If you want to order the query by a custom field you should add 'orderby' => 'meta_value'
AND you must also specify the custom field (called your_date_field
in the above example) using the meta_key
key in the query.
$timeline_query = new WP_Query(array(
'post_type' => 'post',
'orderby' => 'meta_value',
'meta_key' => 'your_date_field'
'posts_per_page' => -1
));
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- Wp get all the sub pages of the parent using wp query
- How to query for most viewed posts and show top 5
- WP_Query vs get_posts
- Query Posts in a Predefined Order
- Order posts by ID in the given order
- Custom WP_Query order by post_meta and (author) user_meta
- Query Custom Meta Value with Increment
- Get posts by meta data OR title
- Perform query with meta_value date
- Order posts by tags count?
- Pass the same object to multiple widgets in a template with one query
- Retrieve or Query Pages by ID
- How do you query wordpress posts using a math formula between multiple meta field values?
- Custom Post order for homepage
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Page navigation doesn’t show when query category
- How can I pick a single post from the latest 3?
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Change query_posts to WP_Query in page but does not work
- Custom Query num_rows returns wrong amount
- How to orderby multiple meta fields if some fields are empty
- Weird orderby => post__in issue
- Slow page loads due to WordPress Core Query
- Order by summing multiple values
- Order by empty custom field
- Query Page Content From Theme Options?
- How can I override one post and make it display content for another post?
- Include current post into loop
- Filter post query to only show direct children of category
- Should I reset $wp_query?
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Why doesn’t my WP Meta Query return any results?
- Filter products on category AND tag
- pre_user_query vs pre_get_posts
- Get posts that match defined arrays of tags
- Meta query orderby meta_value_num sorting by role first
- Order posts by tags count?
- Order by meta date with a thousanth of a second defaults to post order
- How to get_comments() ordered by date and parent?
- I need query_posts() to order results first by a meta value and then by post ID
- WP Query. Ordering posts by another post types meta
- How to show post title in content editor in backend?
- My entry results are not consistently alphabetized
- Merge two queries and remove duplicate
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- orderby in WP_QUERY – Use the order from the Dashboard
- Ordering Posts by parent category, name ascending
- Optimising specific Query with ACF meta objects
- How to organize a WP_Query’s list of posts by category and display category title?
- When should you use WP_Query vs query_posts() vs get_posts()?
- query_posts with sorting on a custom datestamp
- How to query post ids liked by the Author
- WordPress Query showing multiple titles
- Query Posts by date range with fixed beginning and end
- custom query to get posts
- Get posts that were most recently tagged
- new WP_Query with order args – no more distinction between categories
- WP Query where title begins with a specific letter
- WP_Query order by multiple meta keys & fields
- WP_Query: query posts by ids from array?
- pre_get_posts with get_posts
- How to make an activities stream mixing posts and comments?
- How to query for a week using key => value WP_Query argument notation?
- SQL query equivalent to WP User Query
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- Too many posts cause slow load when paginating
- Order Posts by meta value AND published date
- Pass array of taxonomy terms to wp_query
- How to reduce the number of queries?
- List of the years with posts presented
- Query custom post type by custom taxonomy (category slug)
- Editing the default wordpress search
- meta_value_num not ordering all items
- Is there a better way to pull in custom content without querying posts?
- Reset WordPress Post Query to default
- Is_single() conditional tag returns null in query
- Show a 404 error page if Public query variable’s value doesn’t exist?
- How to give classname to post if post has no content?
- Creating attachments archive in tags and categories
- Posts limit on homepage (genesis framework)
- setting offset to category number in archive page
- Query for current post
- Query Posts | Combining multiple form inputs into query arguments to generate one filter result
- Query Order By Number Variable From API
- How to query 5 users in random who have published more than 10 posts
- What is the best way to reset a search on a meta_key / meta_value?
- Pull posts from all categories if quantity is not met?
- Query_post 5 post first / last of post_id
- Bring a post to the top of the query if it’s in a certain category?
- Using URL variables on a custom WP_Query
- Using WP_Query to re-query and sort results using a date?
- orderby in WP_query doesn’t works
- Converting an existing query_posts to WP_Query
- WordPress query very slow on +/- 300k DB entries and 7 INNER JOIN