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?
- 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
- Getting attachments by meta value
- Sorting a query by custom field date
- WordPress Custom Query to show posts from last x years
- meta_query where value is equal to given value
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- datetime picker, timestamps and meta queries
- Sorting Posts by custom field
- Order posts by date and then by custom field
- 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
- meta_key and meta_value not working together
- How add a custom posttype name using ACF field to a query post array
- Compare WP Custom Field date
- Query by custom dates in UNIX Time
- getting posts and number by specific meta value in multiple meta
- Ordering Posts Type A by Custom Fields of related Post Type B
- Search Posts with Custom Fields as query
- 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
- How to make Meta Query case sensitive?
- How to Filter Posts by Custom Fields?
- Fetch Record based on meta key dates
- 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?
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Order by empty custom field
- Large AND OR query timing out
- Categorising search results based on Custom Fields
- Posts published last 10 minutes
- Search posts missing a particular custom field
- wp_query get data from advanced custom field in wordpress
- How to compare a date in custom field with today’s date in custom WP_Query?
- 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
- Intiger meta value with ‘>=’ returns posts with lower value
- Display posts with specific value first in query
- get_posts custom field
- 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
- Excluding posts with certain value of meta_key keeping posts without that meta_key
- Query only displays one page_id
- Querying a large number of posts including their custom fields data
- Display post meta conditionally based on it’s value
- Query using string from custom field as array value
- How to show list of posts with custom field value (a date) that are coming soon
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- meta_query weird behaviour, static int will work, but not user data
- Query multiple post types, but different order for each
- Order by the first array within a meta_query
- Woocommerce Shortcode which displays a table with product data
- Query ACF relationship field – Comparator IN – Value array
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- display ACF repater field in archive page
- query hook parse_tax_query function takes no effect
- Query posts by post type, author and post meta
- How to use the Term Object from a custom select field in a query
- Trouble with serialized metadata
- Categories In English version showing not canonical URL, instead shows query search result
- Comparing Meta Field date in WPQuery using Meta_Query?
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- Query against multiple locations within single custom post type post
- Query post by Category and custom file (ACF)
- WP_Query, ACF field and array
- Problem with my loops
- Order by Date Custom Field
- ACF Post Object meta-query by title not ID
- Sort posts on custom field AND after that sort on date?
- using custom meta user data to run queries in WordPress
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- datetime picker, timestamps and meta queries
- Meta key in wp_query bug?
- Wrap group of wp query posts to parent div by date/year
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Order Custom Field by Price
- WP_Query to show post from a category OR custom field – Not 100% answered
- Sorting Posts with meta value not working
- Custom search (wp query by custom fields)
- How do I display posts with specific value in a custom field into my loop?
- Custom Search Query – include only custom fields and title
- Get posts by meta value except one post [closed]
- WP_Query – order with usort by custom meta
- Best performance for use Custom Field in WP
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string