You can sort a query by a specified post meta field as a number or as a text field.
Example:
$query_args = array(
'meta_key' => 'event_date',
'orderby' => 'meta_value_num'
);
$event_query = new WP_Query( $query_args );
Related Posts:
- Add custom post type items from frontend
- Custom Post Type, WP_Query and ‘orderby’
- Sorting a query by custom field date
- Number of pages – multiple (custom) post types
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Sort by two dates. Default entry date and custom field if present
- Sorting multiple custom post types without a meta key/value pair by sort order
- Combining sorted and random CPT
- Wp_query: sort by PHP variable
- WP_Query order by custom field, then randomly order some of results
- Sort entries by date mixing two post types
- Sort results without WP_QUERY?
- Sorting the Loop by Taxonomy Value
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Sort custom posts by date and then by taxonomy
- How to sort by multiple values in a nested WP_Query
- How to use multiple orderby conditions on query search results? (orderby one post type, relevance)
- Wp Query sort order from custom MetaBox
- sorting in wp query based on custom field value
- Issue with permalinks for custom post type
- How do I sort post listing by child post count?
- Sort CPT by taxonomy AND THEN by custom field
- How do I set the default admin sort order for a custom post type to a custom column?
- Submit post and upload image from front-end
- Exclude a category from WP_Query
- Single loop for wp_query and wp_user_query
- WP_Query orderby custom field then post_date in one query
- query multiple taxonomies
- Include post id[s] into WP_Query()
- Pagination Doesn’t Work
- Using Query Posts With Multiple Post Types And A Taxonomy
- List with categories, subcategories and posts of custom posttype
- Sort the main query in subcategories/terms?
- Custom Taxonomy List links being re-written
- front end radio custom taxonomy with custom post type
- Can’t sort order of wp_query with 2 meta keys
- Get post info inside modal window?
- Get count of custom post type created by current user
- Query Custom Post by Category
- Pagination Issue: Custom Post Type In Index
- Having trouble with custom date field for CPT query (WordPress)
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Custom post query by taxonomy
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- WordPress Create Post from front-end
- How to use WP_Query in a CPT achive page?
- Use get_post_types to query only custom posts types
- Group custom posts by custom taxonomy names
- How can i skip same post from taxonomy term?
- Pagination on a custom post type loop
- WP_Query orderby modified to include custom meta changes
- Wrong request query on cpt and tax
- Custom taxonomy rewrite give pagination 404
- How to get the upcoming post ID from front end?
- How to display post list inside post
- How to have this permalink structure: post_type/postname/custom_inner_page
- Advanced search form with filters for custom taxonomies
- custom post type search by reference id
- Showing specific post in order of array wp_query
- WP the_posts() on single-cars.php get category link
- tax_query not working in template
- Custom Taxonomy Not Showing in Front-End When Outputting a Custom Post Type with WP_Query()
- Submitting Custom Post Types with custom fields from Front-end form
- Custom WP_Query always respond with 200 status even when no entry
- Pagination 404 on Index with custom query
- WP_Query parameter conflict
- Retrieving meta-box from a custom-post-type
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- Sort custom post type by most current date picker
- Update ACF fields on a frontend form? [closed]
- Custom Post Type Archive Pagination
- List all Custom Post Type posts excluding certain Taxnomy term
- Two queries – one with checkbox ticked, one without – comparing meta_query
- Custom post type pagination error
- WP query_posts group by meta field related
- Apply category query clause to posts of custom type
- custom post type and a “sticky” position taxonomy
- Display post count for a specific month
- Query to Exclude Child Pages from Custom Post Type Archive
- WP_query has incorrect wp_posts.post_name = ‘asc’ when I have custom post type called ‘order’
- Randomizing WordPress Custom Post Type Sorting Through Them Without Page Refresh
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- How to output custom post type title on custom page with category next to it?
- WP_Query to display number of custom post type filtered (order by) taxonomy
- 2 modal windows with ACF content on Archive page
- Custom Post Type – Display all, wrap in groups of 3
- Staggering featured post using ‘sticky’
- Ajax load more inside custom post type taxonomy
- Create a custom wp_query from a specific custom post type with specific taxonomy
- Query breaking with ‘posts_per_page’ => -1
- WP Query with multiple post types ordered by custom meta date then published date
- Query Pulling the same post twice
- WP_Query get posts where post_name is empty
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Querying meta values within an array
- Filter Custom post type by another Custom post type
- Archive page – problem with pagination
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- How can I show posts with the same tag?
- Load posts via AJAX without draft status