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
- Advanced search form with filters for custom taxonomies and custom fields
- Meta query with boolean true/false value
- Custom field values deleted when trashing custom post type
- How do I remove all the metaboxes for a custom post type?
- Limit the post for differents custom post type in the same wp_query
- WordPress Admin Panel search posts with custom post meta values along with title
- Rest Api v2 orderby meta_key in custom post type
- bulk Update post_meta with default values
- Multiple templates for custom post type
- Combine tax_query and meta_query in WP_Query
- Query for posts in 2 taxonomies
- How to make an archive page displaying posts in a date range
- Query for custom post type objects in a taxonomy and with a meta value
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- Multiple post type queries (with specific arguments for each)
- How can I get_post_meta() in the most efficient way?
- List all images from a single post meta value
- WP_Query: include custom post type only with specific meta value
- What’s a better alternative to this code?
- how to delete all users and posts based on ‘user_meta’?
- Meta Key Value in current-user-only loop
- Order query using custom meta data
- Get latest 3 posts from multiple CPT in one query
- Widget: Custom Post Type Post Listing Dropdown on Admin Side
- Meta query for custom post type ignored in main query
- How to duplicate entire custom post type
- get_post_meta not working on publishing
- how to make members list directory through wordpress post custom meta key.
- WordPress request fiter order by related post’s post_title
- Query posts based on the meta key values of logged-in users?
- Using preg_replace to filter custom textarea
- query_posts adding extra code to homepage
- Meta data (Tags and Categories) for Custom Posts not showing.
- Display different information of a custom post type
- How to get specific post meta by title or id
- Why are some of my custom posts not showing up on my page?
- How can I display a drop-down select of Post Names
- $post->post_meta not pulling any post in wordpress/php
- Incorrect ordering of custom post type based on time
- Sorting by meta_key different to search criteria?
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- Filter search posts by post meta?
- Custom Post Types Not Showing Up In query_posts Result
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- meta query condition don’t work
- Attaching more than 1 parent (Post) to a media file
- How to get post by meta value
- How do I get all authors posts of a custom post type outside loop
- minimize wp_query call to database
- Custom post type meta fields missing on save_post_type
- Order posts by meta value hiding posts instead of re-ordering
- Meta query broken since 4.7.4 Update
- custom search results – order results differently by post type
- get_post_meta for Custom Post Type ( CPT )
- How to set class to “current-page” on the currently viewed single post within a CPT
- How can I list custom post by custom category?
- Query Posts From Multiple Post Types
- WP Build-In Post selector for CPT
- How to apply order on custom taxonomy and custom meta key on custom post type
- Random meta field from specific custom post type
- Custom Form Data save after Login User
- show custom post’s post in two different divs [duplicate]
- Display ACF object field data using Elementor Custom Query
- Changing to different post type maintains the redirection?
- How do I add the “orange counter” next to a Custom Post Type?