You’re pretty close, but I wouldn’t be distracted by the ‘scope’ meta key. The following is untested.
<?php
$args = array(
'post__not_in' => array($donotrepeat),
"post_type" => 'event',
'meta_key' => '_event_start_date', // name of custom field
'orderby' => 'meta_value',
"order" => 'ASC',
"posts_per_page" => 1,
'meta_query' => array(
array(
'key' => '_event_start_date',
'value' => date('Y-m-d'),
'compare' => '>=',
'type' => 'DATE'
)
),
);
?>
The meta_key is only present for ordering – meta_query controls the actual selection.
Note that I left your posts_per_page as is, even though it will limit the selection to one record.
Related Posts:
- Meta Query with AND & OR?
- Loop to display random posts only if a custom field matches category
- Conditional custom field query
- Order by empty custom field
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- Can’t query by meta_key
- Loop through incrementing custom fields
- The best way to collision check in WP
- How to query for posts with either one or another custom field
- Compare ACF date field (if exists) and post date and order DESC
- Loop through multiple custom fields with increasing number
- Complex WP_Query Using Post Date And Post Meta
- Display posts where date field matches current month?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Query multiple custom post types in single loop
- Filter WP_Query for posts having a certain meta-value
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- How to use a custom post type as front page?
- How to rename a custom field?
- How do I search an array stored in a custom-field using WP_Query?
- 2 orderby in wp_query with 2 custom fields
- How to get a meta value from all post
- Compare meta_query decimals not working right
- Loop through two different sets of custom fields
- Query Problem – Show posts within category ‘x’ that have a custom field between ‘y’ and ‘z’
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- meta_query on a date range using an array of values
- How to Loop within a Loop (Display Children and then Grandchildren)
- Having trouble with custom date field for CPT query (WordPress)
- Plugin similar to Taxonomy Drill-Down for custom fields?
- Order by value in serialized custom field
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- Conditional to modify query results
- How do I exclude posts by custom field value?
- Echo values from custom field outside loop php
- Any way to include custom fields in WP_Query results?
- sort search results by custom fields using dropdown
- WP_Query orderby modified to include custom meta changes
- How can I show custom fields in the loop only to specific user roles?
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How to Filter Posts by Custom Fields?
- Auto Populate Custom Field with Complex Value That Increase by One?
- query usermeta from custom field
- Is there any way to get all meta and standard columns for any WordPress object after searching based on meta key and value
- Limit the number of acf content when displaying in post loop [closed]
- Get a list of posts with associated meta_value
- Is there a better way to list all database terms alphabetically?
- How to get list of posts from permalinks?
- List users by sum of all their posts’ custom field values
- How to combine custom fields to make one order-able value
- Trying to reorder posts by custom field
- Limits, not all post are showen when querying for posts by view count
- Custom Fields – How to create a list from multi-line entries of a single value
- Custom Query based on custom field of a single post
- Transient api Caches confused
- How to overwrite orderby with add_query_var
- Select custom posts by meta_value and sort by a different meta value
- Adding custom field and querying from post table
- Conditional operator OR not working with custom fields
- List custom queried terms in the edit-tags.php?taxonomy page
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Should I reset $wp_query?
- WP ForLoop to compare meta information of posts to determine what post to display
- How to filter query loop block with a search string from the query parameters
- ul list with only as many li’s as filled custom fields
- Query only displays one page_id
- I am officially missing something about transient posts
- Collect Data from NEXT item while in loop
- Get array of posts based on custom field values
- Display metabox title for custom fields with values
- How to update custom field of a posts in a particular category
- How to query posts by month based on date custom field?
- How can I modify my meta_query to work with prices that are stored in the database that contain dollar signs and commas?
- Filter or order based on custom field
- Query multiple post types, but different order for each
- Problem with revisions only returning four results
- WP Query from two Custom Post type fields as statement
- display ACF repater field in archive page
- Query against multiple locations within single custom post type post
- Problem with my loops
- User Filter Options on Archive Page
- searching by keywords in post’s metas or pagination links problem
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- get wordpress post loop by meta box date
- how to show more than 1 post into three columns query
- Counting number of images from loop
- How do I display posts with specific value in a custom field into my loop?
- WP Query multiple select form – meta_query help
- query specific posts according their custom fields, using sql SELECT
- WP_Query based on multiple metadata comparisons
- Get multiple posts with some custom fields efficient
- I want my post to republish again after adding a custom field
- How to check if custom field exists in this widget query
- Only show content slideshow if “slideshow” custom field exists
- Filter Custom post type by another Custom post type
- Pagination not displaying correct number of pages
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Query posts by Custom Meta (checkbox) & Genesis Grid Loop
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise