First, you have to store your dates in a form that sorts properly mathematically. Unix timestamps will do that. The only human-like calendar format that does it is YYYY-MM-DD
. You have your dates saved backwards.
Assuming you store as YYYY-MM-DD
, then this should work:
$args = array(
'meta_query' => array(
array(
'meta_key' => 'ows_schedule_field-date',
'meta_value' => array($date_one,$date_two), // both dates YYYY-MM-DD
'compare' => 'BETWEEN'
)
)
)
$posts = new WP_Query($args);
Related Posts:
- Use WP_query to match post types based on custom field values
- what is the correct way to compare dates in a WP query_posts meta_query
- Using meta_query, how can i filter by a custom field and order by another one?
- Fail to compare dates in meta_query
- Ordering posts having multiple post-meta date fields
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How Can I save multiple records in same meta key?
- I can’t set meta_key in my custom post type query
- order by meta_value serialized array
- Using Query Posts With Multiple Post Types And A Taxonomy
- Can’t sort order of wp_query with 2 meta keys
- Used with meta_query in query_posts works slowly
- Conditionally Query Custom Post Types by Post Meta for Blog Home Page?
- Display custom post types with custom date field value (before today) & order by custom date field
- Displaying Metabox value (custom post type taxonomy)
- Display custom post type from dynamic custom field
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Filter date from post meta when date is in string format
- Querying multiple values from a single key
- find custom post type post by searching its custom field with my string
- WP_Query of custom post type sorted by meta_key has unexpected results
- WP_Meta_Query object with conditionals
- HM CMB: Post Select Field for CPT ID
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Show posts from WP Custom Post Type selected from a field in a metabox
- update a posts of other custom post type
- meta query always fails even if data is correct
- WordPress custom post type
- Filter RSS feed for custom post type to events for next 7 days only
- Custom Query With Multiple Meta Key Value
- Return only custom post types for the page, not all
- Querying meta values within an array
- Check for custom field value in different post type than current one and do something
- getEntityRecords/useEntityRecords: How to use CPT metadata?
- Custom post type: “transition_post_status” action get title and other fields
- Not able to get my custom search result using meta_query and tax_query together?
- Add more custom fields when creating a new custom post type
- Meta query broken since 4.7.4 Update
- Custom meta box data not saving
- custom search results – order results differently by post type
- How do I extract the contents of a CPT’s custom field for all posts?
- Stripe multiple transactions
- Collect custom post in a calendar
- Storing data in a multidimensional array from dynamically generated foreach loop
- How to shows CPT which has specific meta key?
- How to Create movie schedule by custom post type query
- How to get Current week and current date record wp query
- Ordering Posts By Meta Data
- How to get post meta for custom post type and taxonomy
- Querying, storing, and using data from 2 separate custom post types
- get_post_meta for Custom Post Type ( CPT )
- How do I get the posts from single page custom post type from a sidebar to display in a page?
- Main site single-property.php design, as homepage of a multisite
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- How to set class to “current-page” on the currently viewed single post within a CPT
- Delete custom post type metadata without deleting the post in admin area
- Edit is changing my custom’s post type parent id
- Imported Content Doesnt Show Up On Frontend
- Order by post meta value gets random results
- Optimise custom post type queries
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- Disable Facebook Comments Automatically On CPT
- How to add post reference field to a plugin?
- Problem with ‘save_post’ hook not running
- How to get Last post Id of custom post type in wordpress
- How to get main div html to print a list of posts inside?
- Display 2nd category, only once, as sub-heading, in the loop
- WordPress custom post type queries
- Edit post meta direct from post.php?
- display news with pictures 3 small and one large (loop)
- shortcode order for event custom post type
- Events with multiple event dates + permalink for each date
- Howto: use existing post_meta as options for a different metabox (checkboxes or list)
- Selecting posts older than the current Unix epoch timestamp
- Custom Post Type meta oembed html output resulting in WSoD
- Unable to get the upcoming events for custom post
- Values inside a custom field to determine which category posts to display
- How to create content automatically when a post is published?
- Using $seed on a custom post type for randomly displayed posts
- Display a post count from a custom metabox selection
- query_post causes the posts to be loaded twice on load more posts
- Query Distinct Taxonomies of Custom Post Type
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Ordering custom post type by custom field without a title
- Custom post type blog pagination conflict
- How can I list custom post by custom category?
- How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?
- Rich Custom Field for Custom Post type not saving
- Query Posts From Multiple Post Types
- Add auto increment value to custom meta
- Custom post type submenu sorted by specific meta_key & meta_value
- Trying to combine multiple WordPress queries
- using post_type with meta_query
- Ordering by multiple meta keys – Custom post type
- Advanced Custom Fields: query posts filtered by multiple field values
- Change the contents of a dropdown through the admin panel?
- WP Build-In Post selector for CPT
- Advanced search form with filters for custom taxonomies and custom fields