I think your query arguments are missing meta_key
, which in this case should be 'event-date'
. You need it outside the meta query for orderby to work. Try this:
$today = date("Ymd", strtotime(current_time('mysql')));
$args = array(
"post_type" => "post",
"post_status" => "publish",
"posts_per_page" => -1,
"cat" => 13,
"meta_query" => array(
array(
"key" => "event-date",
'type' => 'NUMERIC',
'value' => $today,
"compare" => ">="
)
),
'meta_key' => 'event-date', // meta_key added
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$eventsbody = new WP_Query($args);
Related Posts:
- Query posts using less than
- Can wp_query return posts meta in a single request?
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?
- Function in array as arguments for WP_Query
- WP_Query to show post from a category OR custom field
- Sorting posts by custom date fields (non standard date format)
- Getting attachments by meta value
- Sorting a query by custom field date
- Using WP_Query To Get Posts Randomly From today
- WordPress Custom Query to show posts from last x years
- meta_query where value is equal to given value
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- Get_post() with meta_key when compare is a date
- querying with custom meta field with meta_query
- Group posts by custom field
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- datetime picker, timestamps and meta queries
- How to get the posts published in last two days using WP_Query?
- getting posts and number by specific meta value in multiple meta
- How to query using a combination of custom_field values?
- Sorting Posts by custom field
- Order posts by date and then by custom field
- Revolution Slider Orderby Two Custom Fields
- Query two post types and order by two different date fields
- List taxonomy terms plus their latest post ordered by post date
- WordPress altering my custom query, How to fix it?
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- Order by meta_key in custom post type doesn’t affect the query
- How to filter a dd/mm/yyyy date from a custom field in a query
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- meta_key and meta_value not working together
- How can i make WP_Query return post image and categories?
- Date query not inclusive despite parameter being true
- Use meta_query to display events by date in custom field
- wp_query with multiple custom fields
- How add a custom posttype name using ACF field to a query post array
- Filtering posts by custom field value not working
- Compare WP Custom Field date
- Query by custom dates in UNIX Time
- Display link to taxonomy archive only if it has posts with certain custom field values
- getting posts and number by specific meta value in multiple meta
- Ordering Posts Type A by Custom Fields of related Post Type B
- Order Posts by meta value AND published date
- Search Posts with Custom Fields as query
- wp_query add arguments using array_push if variable met
- Group WP_Query by meta_key date
- How To Fix WP Query Returns Results But Shouldn’t?
- Get posts for which a custom field is not present, with get_posts
- Output an array of terms for a ‘tax_query’ => array()
- exclude posts with a specific custom field and value
- Add quicklink to in the Admin posts page where I can query by a meta_key
- How to make Meta Query case sensitive?
- How to Filter Posts by Custom Fields?
- Display custom field meta outside loop, site wide
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- Fetch Record based on meta key dates
- Meta_query with multiple keys and multiple values
- Orderby is working with one query but not with other
- meta_query BETWEEN, but the range is stored in the custom field
- Get a list of posts with associated meta_value
- WordPress Comments sort by custom meta key
- Understanding the orderby in WP_Query?
- Extend product search with meta in WooCommerce
- How to list custom fields as headers and list all pages sharing that custom field under it?
- how to make members list directory through wordpress post custom meta key.
- Order by empty custom field
- Query posts without meta preload
- Adding multiple meta_key fields as orderby options to a WP Query via a function
- Large AND OR query timing out
- meta_value_num not ordering all items
- Categorising search results based on Custom Fields
- 2 weeks ago from meta query meta value
- Posts published last 10 minutes
- Query all posts if multiple meta key don’t exist
- WP Group posts by year(desc) > month(desc) > date(asc)
- meta_compare not comparing whole integer
- Search posts missing a particular custom field
- wp_query to print posts if have X custom field value
- wp_query get data from advanced custom field in wordpress
- Why is WP_Query not displaying expected data?
- How to compare a date in custom field with today’s date in custom WP_Query?
- WP_Query Meta_key is text value and need to sort as numeric not working
- filter wp_query result with custom field values
- Order post type by sum of two custom fields
- Conditional operator OR not working with custom fields
- WP ForLoop to compare meta information of posts to determine what post to display
- WP_QUERY with group by with custom fields
- How to order posts on each different category?
- Intiger meta value with ‘>=’ returns posts with lower value
- Display posts with specific value first in query
- get_posts custom field
- Get every post with value in meta key
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- wp_query posts with custom fields number smaller than
- Posts query according to meta box date
- create metabox to activate slider
- Retrieve select tag custom values from array and display them in current page with wp_query?
- How to use a dropdown to filter posts by custom field