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?
- how to make nsfw post with thumbanil
- Custom Query based on custom field of a single post
- Transient api Caches confused
- Get post ids sorted by meta_key
- Efficiently sort only certain categories by custom field
- querying a custom field
- Can I access a post meta field before the loop?
- Passing meta_box string to post__in?
- Displaying page image in the footer automatically
- Include current post into loop
- pre_get_posts : only get posts by wp_usermeta value
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- Exclude taxonomy term from all loops, but having it on widget
- meta_value and meta_key filtering returning no posts [closed]
- Show image if author meta (profile fields) exists outside loop
- Select custom posts by meta_value and sort by a different meta value
- Adding custom field and querying from post table
- How to query an out put value?
- Conditional operator OR not working with custom fields
- How to conditionally add Custom Post Type to Front Page
- 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
- Modify date query by URL parameter using pre_get_posts and $_GET
- ul list with only as many li’s as filled custom fields
- Query only displays one page_id
- Custom search SQL Query to add custom field in result
- do_shortcode close
- Search Results Page – Displaying Custom Meta Fields
- Meta query relation ‘OR’ not working as expected
- I am officially missing something about transient posts
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- WP_query multiple custom fields not working
- Collect Data from NEXT item while in loop
- How to exclude custom fields from search queries?
- WP_Query () using taxonomy, custom post types
- Custom Query Fields – Altering Meta Value
- Multiple Custom Field Query
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- How do I list a custom field and custom taxonomies for each result in a loop?
- How to show content of custom fields in search results?
- Custom Query: query by post custom meta data
- Custom field outside the loop and inside an array
- Get array of posts based on custom field values
- Display metabox title for custom fields with values
- use custom field value as post category in loop
- How to update custom field of a posts in a particular category
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- 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
- Custom Field Date Problem
- Query multiple post types, but different order for each
- What am I missing in this Code Block?
- get_field values for each post on home page using wp_add_inline_style
- Problem with revisions only returning four results
- Search & column order by meta value in admin
- WP Query from two Custom Post type fields as statement
- display ACF repater field in archive page
- Dynamically populate query source in Elementor post widget
- WP_Query not ordering correctly
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- Query against multiple locations within single custom post type post
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Problem with my loops
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- WP_Query & Duplicate entries
- User Filter Options on Archive Page
- searching by keywords in post’s metas or pagination links problem
- sorting in wp query based on custom field value
- Query by meta value (add a dropdown of all values)
- Custom meta boxes – add php code inside?
- 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
- Outputting custom field on home.php not outside of blog list
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- Counting number of images from loop
- Metabox value for post loop?
- Ordering Posts by parent category, name ascending
- Get meta value when the page is a blog archive