$args = array(
'post_type' => 'event',
'meta_key' => 'start_date',
'meta_type' => 'DATE',
'orderby' => array(
'start_date' => 'ASC',
'menu_order' => 'ASC',
)
);
$posts = get_posts( $args );
Related Posts:
- When to use WP_query(), query_posts() and pre_get_posts
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query vs get_posts
- Sorting: custom query with orderby meta_value_num THEN by title
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- Get posts from Network (Multisite)
- Sanitation needed for WP_Query or get_posts calls?
- How to get order of posts?
- Get Recent Posts by Date in Multisite
- Use of caller_ get_ posts
- How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?
- WP Query orderby meta key natural sort?
- How-to exclude terms from the main query the most performant way?
- Query all posts where meta value is empty
- Get_post() with meta_key when compare is a date
- get_posts not finding argument: post_name
- Meta Query with date and time on the same Day before given time
- Get posts with condition on comment meta value
- What should I use, get_posts or wp_query for less CPU load?
- How to get post from all Blog Multisite to the Main Site?
- Sorting meta_value as integer doesn’t work
- Sort in WP_Query(), not filter? Is it possible?
- get_posts() seemingly ignoring post_type
- Can not switch the queried post in pre_get_posts hook
- Front End Sorting Questions
- Woocommerce custom loop to show all the products [closed]
- Count posts returned by get_posts in external PHP script
- How to sort posts in admin by titles with dd.mm.yyyy format?
- SELECT * FROM $wpdb->posts WHERE ID > 160
- Adding multiple post queries with parent and children to page – Best Way
- WP_Query, tax_query and term_meta: How to?
- get_posts – get all posts by array of author
- Creating a custom search for a specific post type
- get_posts – find out if querystring was crap and fallback is used
- Creating query to show which editor (classic or block) was last used to edit a post/page
- get_posts() not working with multiple statuses
- Return only post(s) which have post_excerpt
- WP_Query() and get_posts() can’t handle over a thousand posts?
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- WordPress Comments sort by custom meta key
- Understanding the orderby in WP_Query?
- Help ordering Post loop by two meta values
- WP_Query post_parent parameter always returns children of current page
- How to sort a custom wordpress query by combination of meta values?
- How to show more post at a given category?
- How to count posts with specific arguments
- Does wp track views for posts?
- I am having problem sorting custom post type using WP_Query
- get_posts output always same post
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- get_posts() and global variables
- complex get_posts() query to select child pages
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- Display all posts in a custom post type, grouped by a custom taxonomy. How to sort the posts alphabetically and the terms by ID?
- WP Query and date format
- How to get posts by category and by choosing a taxonomy term?
- Function using get_posts() with tax_query not working when called from functions.php
- Search for pages with permalink
- How to sort queried pages by an array of page ids?
- How to query for a page, get data, then query for child pages of that page
- Execute PHP function inside the admin area
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Why my query is not “Main_query”?
- Facing problem with tax_query results
- get_posts query is taking about 40 seconds to execute
- Customize the Sorting Dropdown in WooCommerce use another list or more page
- Order (by ASC) posts with meta_key so posts without values are last
- Populate select list with meta values from all posts of a Custom Post Type
- Form checkbox value going to dynamic URL
- how to include orderby value that is empty?
- How to sort wordpress posts already selected by WP_QUERY
- Custom Woocommerce Product Query
- How sort products by calculate value? ( custom post meta, price, option)
- get_posts return only first result
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- How to get meta key list efficiently?
- Order by value of Custom Field using url string
- WP Query with meta queries
- how to get wp_query posts only first letter of alphabet A?
- Case insensitive ORDERBY in wpquery
- How to mix two orderby-parameters into one ordered result
- Sorting Posts by Taxonomy thats not within the query’s $args
- Ignoring ‘a’ when sorting posts
- I cannot get tax_query in get_posts() to work with custom taxonomy
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- Ordering Posts by parent category, name ascending
- Use not custom fields in get_posts() meta_query?
- Mathematical operations on custom field values? (updated)
- Sorting is not working in WordPress WP_Query
- get_posts works but new wp_query doesn’t
- query_posts with sorting on a custom datestamp
- Why WP_Query in functions.php is not working when get_posts works?
- Retrieve posts in custom post type and specific taxonomies
- Query specific number of posts for each post type in specific order
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- get_posts shows current post, not defined posts with args
- Query custom post types by meta field in a term from custom taxonomy
- have_posts order by title descending
- WP_Query – order with usort by custom meta
- How to retrieve _embed (etc) fields in get_posts custom query?