Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Get posts between custom dates

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:

  1. Use WP_query to match post types based on custom field values
  2. what is the correct way to compare dates in a WP query_posts meta_query
  3. Using meta_query, how can i filter by a custom field and order by another one?
  4. Fail to compare dates in meta_query
  5. Ordering posts having multiple post-meta date fields
  6. Custom Queries: Joining On Meta Values From Two Custom Post Types
  7. How Can I save multiple records in same meta key?
  8. I can’t set meta_key in my custom post type query
  9. order by meta_value serialized array
  10. Using Query Posts With Multiple Post Types And A Taxonomy
  11. Can’t sort order of wp_query with 2 meta keys
  12. Used with meta_query in query_posts works slowly
  13. Conditionally Query Custom Post Types by Post Meta for Blog Home Page?
  14. Display custom post types with custom date field value (before today) & order by custom date field
  15. Displaying Metabox value (custom post type taxonomy)
  16. Display custom post type from dynamic custom field
  17. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  18. Filter date from post meta when date is in string format
  19. Querying multiple values from a single key
  20. find custom post type post by searching its custom field with my string
  21. WP_Query of custom post type sorted by meta_key has unexpected results
  22. WP_Meta_Query object with conditionals
  23. HM CMB: Post Select Field for CPT ID
  24. Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
  25. Show posts from WP Custom Post Type selected from a field in a metabox
  26. update a posts of other custom post type
  27. meta query always fails even if data is correct
  28. WordPress custom post type
  29. Filter RSS feed for custom post type to events for next 7 days only
  30. Custom Query With Multiple Meta Key Value
  31. Return only custom post types for the page, not all
  32. Querying meta values within an array
  33. Check for custom field value in different post type than current one and do something
  34. getEntityRecords/useEntityRecords: How to use CPT metadata?
  35. Custom post type: “transition_post_status” action get title and other fields
  36. Not able to get my custom search result using meta_query and tax_query together?
  37. Add more custom fields when creating a new custom post type
  38. Meta query broken since 4.7.4 Update
  39. Custom meta box data not saving
  40. custom search results – order results differently by post type
  41. How do I extract the contents of a CPT’s custom field for all posts?
  42. Stripe multiple transactions
  43. Collect custom post in a calendar
  44. Storing data in a multidimensional array from dynamically generated foreach loop
  45. How to shows CPT which has specific meta key?
  46. How to Create movie schedule by custom post type query
  47. How to get Current week and current date record wp query
  48. Ordering Posts By Meta Data
  49. How to get post meta for custom post type and taxonomy
  50. Querying, storing, and using data from 2 separate custom post types
  51. get_post_meta for Custom Post Type ( CPT )
  52. How do I get the posts from single page custom post type from a sidebar to display in a page?
  53. Main site single-property.php design, as homepage of a multisite
  54. Query events post type after current date and timezone
  55. Conditional posts in WP_query for search
  56. How to set class to “current-page” on the currently viewed single post within a CPT
  57. Delete custom post type metadata without deleting the post in admin area
  58. Edit is changing my custom’s post type parent id
  59. Imported Content Doesnt Show Up On Frontend
  60. Order by post meta value gets random results
  61. Optimise custom post type queries
  62. How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
  63. Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
  64. Disable Facebook Comments Automatically On CPT
  65. How to add post reference field to a plugin?
  66. Problem with ‘save_post’ hook not running
  67. How to get Last post Id of custom post type in wordpress
  68. How to get main div html to print a list of posts inside?
  69. Display 2nd category, only once, as sub-heading, in the loop
  70. WordPress custom post type queries
  71. Edit post meta direct from post.php?
  72. display news with pictures 3 small and one large (loop)
  73. shortcode order for event custom post type
  74. Events with multiple event dates + permalink for each date
  75. Howto: use existing post_meta as options for a different metabox (checkboxes or list)
  76. Selecting posts older than the current Unix epoch timestamp
  77. Custom Post Type meta oembed html output resulting in WSoD
  78. Unable to get the upcoming events for custom post
  79. Values inside a custom field to determine which category posts to display
  80. How to create content automatically when a post is published?
  81. Using $seed on a custom post type for randomly displayed posts
  82. Display a post count from a custom metabox selection
  83. query_post causes the posts to be loaded twice on load more posts
  84. Query Distinct Taxonomies of Custom Post Type
  85. Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
  86. Ordering custom post type by custom field without a title
  87. Custom post type blog pagination conflict
  88. How can I list custom post by custom category?
  89. How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?
  90. Rich Custom Field for Custom Post type not saving
  91. Query Posts From Multiple Post Types
  92. Add auto increment value to custom meta
  93. Custom post type submenu sorted by specific meta_key & meta_value
  94. Trying to combine multiple WordPress queries
  95. using post_type with meta_query
  96. Ordering by multiple meta keys – Custom post type
  97. Advanced Custom Fields: query posts filtered by multiple field values
  98. Change the contents of a dropdown through the admin panel?
  99. WP Build-In Post selector for CPT
  100. Advanced search form with filters for custom taxonomies and custom fields
Categories custom-post-types Tags custom-post-types, meta-query, post-meta, query-posts
Dealing with a library that depends on jQuery
Installed domain-based Multisite but can’t access wp-admin (redirect loop)

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress