&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
- How to Get All Posts with any post status?
- posts_per_page no limit
- How can i get count from query post
- query_post by title?
- Why query_posts() isn’t marked as deprecated?
- Alternative to query_posts for main loop? [duplicate]
- How to get posts published between a date and today?
- how to query posts by category and tag?
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- WP_Query orderby date not working
- Order by meta value or date?
- How do I query by post format in WordPress 3.1
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Filtering posts by post meta data
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- Query posts by custom taxonomy ID
- Display/query post formats
- Order by & include array by specific post ids
- How to query post by user role?
- How to return results of a get_posts() in explicitly defined order
- Query Posts in a Predefined Order
- Help to condense/optimize some working code
- Order posts by ID in the given order
- How to set posts per page using WP_Query()
- query_posts exclude a meta key
- How do I create a random post that will last for a day
- Ensuring sticky posts are retrieved first (without using two queries)?
- Determine if more posts are available than was asked for in `query_posts()`?
- Modify main WordPress loop with a parse_query filter
- query_posts() in function makes global $wp_query out of sync?
- How to put last edited entry on top of the blog-post list?
- WordPress Custom Query to show posts from last x years
- Limiting query_posts to 1, regardless of sticky post?
- How to make “sticky” pages (and query by them)
- 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
- Problem with ‘post__not_in’
- How to order posts by descending comment count on taxonomy page?
- Query posts from current year
- Post date vs. event date in WordPress
- Sort posts alphabetically by custom field value, insert divider between different letters
- 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?
- WP_Query ordered by custom field that is a date string?
- Sort X categories by last update and show image
- Custom Post Type “Event”: chronological list of recurring events
- using post__in allow duplicate post id
- Pagination on archive.php page
- WordPress Custom Query
- Best way to load page content in Fancybox popup?
- How should I intercept the main query and inject custom join / order by / group by criteria
- advice on creating a ‘related posts’ query like the one used on stackexchange
- order post my meta value m/d/y format with year as included value
- Order by meta value, pro first, then free
- Having trouble generating pagination links on custom query
- How to create an attachments archive with working pagination?
- _wp_page_template to dynamically use template
- Using dynamic conditions in ‘posts_where’ filter
- Order by custom field date with ASC order
- Help altering a query to exclude all but standard post format
- List users with the most total posts view
- Schedule Sticky Posts
- Use union/intersection query_posts variables in uri request parameter form?
- How to limit search to first letter of title?
- query_posts and pagination, still stuck after much research
- Query posts by taxonomy term name
- Sorting problem with ‘query_posts’ funcion in wordpress. Sort by custom field not working
- Total Count of Posts NOT in Selected Categories?
- Custom query with query_posts doesn’t show post without certain meta_key
- how could I get the pagination as I want to when query posts using get_posts function
- Counter code for paginated category pages in wordpress
- Arrange Posts By Date In Order Of Closest To The Current Date
- Post Title displaying but not in the wrapped HTML I need
- WordPress Search Filter Only for Page with Child of Child of Child of Child of Child
- Ordering posts by anniversary using only day and month
- Replace query_posts with pre_get_posts
- ascending order custom post type
- How to sort by meta value?
- Retrieve taxonomy terms in order of their post’s date?
- query_posts sort in multiple directions
- Filter query_posts by tag slug on “Tag Archive” page (when tag is 2 or more words)
- pagination in author.php template returns 404 error
- get_post_meta causes database queries