&orderby=date
will return posts by their dates.
<?php query_posts('post_type=page&post_parent=2&posts_per_page=-1&orderby=date&order=ASC'); ?>
Replace first line with this to show post according to their date.
Reference – Passing variables to query_posts
Update –
To sort the posts as per custom field value, Here’s the new code.
query_posts('post_type=post&posts_per_page=-1&orderby=meta_value&meta_key=next_open_day&order=ASC'); ?>
Note – The date should be saved in – YYYY-MM-DD
format. However we can further convert that date into required format. E.g. –
<?php
$date = "2012/08/21";
list($y, $m, $d) = split("https://wordpress.stackexchange.com/", $date);
$newdate = $d."https://wordpress.stackexchange.com/".$m."https://wordpress.stackexchange.com/".$y;
echo $newdate;
?>
Related Posts:
- Display posts of the last 7 days
- query_posts doesn’t order by title
- Author List page: Exclude based on last post date
- Order by meta_key with two meta_queries
- Ordering terms before displaying posts
- orderby:date not working
- WordPress query_posts and orderby page order
- Order posts by condition
- order posts by meta value on posts page
- define orderby URL with meta_key=post_views_count
- WordPress query reverse order
- Meta query stopped working
- How do I query based on the modified date?
- Filter posts by current date ( WP Post Carousel )
- Order posts by ACF checkbox
- Show previous month’s posts
- orderby not working for query_posts using array of IDs
- posts_per_page no limit
- Alternative to query_posts for main loop? [duplicate]
- Query posts by custom taxonomy ID
- Order posts by ID in the given order
- Query posts: how to exclude results if post is in multiple categories
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- How to order posts by descending comment count on taxonomy page?
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- WP 5.8 “Query Loop” block: where to place custom query?
- Pagination on archive.php page
- Best way to load page content in Fancybox popup?
- order post my meta value m/d/y format with year as included value
- _wp_page_template to dynamically use template
- Schedule Sticky Posts
- Total Count of Posts NOT in Selected Categories?
- ascending order custom post type
- Problem with single-page for my custom post
- Display custom post types by date field
- How to modify the query to exclude posts by slug?
- How to make the list of post and load on same page with sub-pages [closed]
- Ordering by meta_value AND date NOT WORKING with wp_query
- How to get 4 Posts after the 5 most recent ones
- post_status => publish not working
- How do I make archives.php for one category only?
- making random query button using $_GET
- Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?
- How do I change the default sort order of a custom column on the posts page?
- how to exclude “featured” posts from the main loop?
- WordPress pagination showing same posts on each page
- pass query string on url to filter media
- Search breaks when querying main loop for category
- Authors List page – How to include only those with wp_user_level as Author
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Adding conditional content to single post-type template
- Hook to return true when the_post() is used in a custom while loop
- Query posts by meta_key whose value is an array
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- using query_posts to pull posts out of a category in a while loop. Getting odd echo
- Echo a numerical value in query_posts
- why to use query_posts() in custom page?
- Query posts to get all but the most recent post
- Always using the same ARRAY on different querys
- Currently using a query_posts() in my theme – want to use a request filter in stead
- How do I use pagination in WordPress?
- Breadcrumbs stop working on a specific template file
- Multiple posts/pages in one page?
- Order for custom field after the loop
- Custom post query error
- Getting images from media library and get_the_date() not working
- Multiple instances of query_posts
- Different layout based on post amount?
- If Query Post Returns 1 Post
- Calling Posts from Specified Cat
- Keeping get_posts’ offset and is_paged() synchronized
- odd behaviours from template tags
- How to get any type posts include attachments by ids?
- Modify main loop query for paged and meta key
- wordpress query_posts featured page always on top
- Create a Loop with Posts Ordered by Most Recent Comments
- Need to add a space after meta value in query_posts in wordpress for zipcode search
- Tax query get first product with attribute value in pre_get_posts
- Specifying image size used in template the_content
- allow user to edit posts made by others users based on the user role
- Ordering Posts By Meta Data
- No duplicate tags by category
- Custome column sort by date not title
- query_posts with sorting on a custom datestamp
- Post per page not working
- query_posts result differs from wp_query request result
- If meta_key has value = 6 | Change the wp_posts.post_date to current date
- Query Posts by date range with fixed beginning and end
- Query posts based on parents attribute
- Adding Category Argument into an Array for WordPress Query
- Collect posts from last 48 hours
- The_content display a different content from a previous loop
- How to go to tag archives using a form
- Run second query on page based on author of the first query
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Why doesn’t this page query work?
- Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work
- Sort posts with multiple meta_keys
- Create “archives by year and week” by category template
- new WP_Query with order args – no more distinction between categories