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

How to query two meta fields and display results between them

You will need to use the meta_query variable like so:

$start = time(); //Now
$end= strtotime('+1 month'); //1 month ahead

query_posts(
    'post_type' => 'event',
    'post_status' => 'publish',
    'posts_per_page' => '10',
    'meta_query' => array(
        array('key' => $prefix.'event_start_timestamp', 'value' => $start, 'compare' => '>=', 'type' => 'NUMERIC'),
        array('key' => $prefix.'event_end_timestamp', 'value' => $end, 'compare' => '<=', 'type' => 'NUMERIC')
    )
);

Related Posts:

  1. How to make search include data from wp_postmeta?
  2. How do I search events between two set dates inside WP?
  3. Search custom post type by meta data
  4. Custom Permalinks Break Search Pagination
  5. Searching by meta values showing inappropriate result
  6. How to make search include data from wp_postmeta?
  7. How do I search events between two set dates inside WP?
  8. Post 2 Post Site Search
  9. Search queries don’t seem to work?
  10. Modifying post content with the_post action hook
  11. meta post search
  12. Sort by postmeta on when searching
  13. searching by keywords in post’s metas or pagination links problem
  14. search for single meta_key with numeric array of meta values
  15. meta field search too restrictive in pre_get_post() for custom search
  16. SQL: Search query to get attachments only of those parents which are published
  17. Form Data Causes “Page Not Found”
  18. Consistent and Admissible Heuristics
  19. Solr vs. ElasticSearch
  20. How do you make Vim unhighlight what you searched for?
  21. grep for special characters in Unix
  22. Search is always exact [closed]
  23. Advanced search form with filters for custom taxonomies and custom fields
  24. how to limit search to post titles?
  25. How to create live autofill search?
  26. order by numeric value for meta value
  27. How can I implement a location based (zip code) search in WordPress?
  28. How to highlight search terms without plugin
  29. How do I remove Pages from search?
  30. Empty search returns home page, how to return not found search page?
  31. How to search for (partial match) display names of WordPress users?
  32. How does WordPress search work behind the scenes?
  33. Remove some pages from search
  34. Limit search to latin characters
  35. How to look at code in WordPress repositories without downloading?
  36. Extend WordPress search to include user search
  37. Display search results within the same page
  38. Empty search input returns all posts
  39. How can i move search results onto a specific page?
  40. Remove meta robots tag from wp_head
  41. WordPress blog with 30 000 posts: poor search performance
  42. Template issues getting ajax search results
  43. WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
  44. Insert DIV container below 1st search result
  45. Unified search across separate WordPress installations
  46. Search in WordPress – Difference of searchpage.php, searchform.php and search.php?
  47. what are the numbers between curly brackets in search query
  48. How to make WordPress search prioritise page titles?
  49. How to add the author search in the default wordpress search?
  50. Admin Area Custom Type Search By Meta Fields Without Title & Content
  51. How do I filter the search results order?
  52. How to insert a span inside a search form?
  53. How do I redirect /search/ to wordpress search template?
  54. How do I Paginate Search Results for Custom Post Types?
  55. Dealing with Many Meta Values, 30+
  56. How to search for users based on added user metadata
  57. Search by Post ID and display content of the post in search result
  58. What is the most efficient way of querying posts based on visits and date for current day?
  59. Extending search query with additional $sentence value
  60. Link to search page without search parameter
  61. Search/Replace for editor in HTML-mode
  62. Search only blog posts (default WP search widget)
  63. Exclude pages from WordPress search result page
  64. How to pass a search $_GET parameter to a new custom search page?
  65. Do I need to sanitize WordPress search query?
  66. Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
  67. Filter the query ONLY for the search results page
  68. Search Using Post ID
  69. Neither the_excerpt() nor the_content() works properly?
  70. Let user change posts per page
  71. Custom Queries: Joining On Meta Values From Two Custom Post Types
  72. WP User Query with search columns and meta query
  73. Exclude top-level pages from search results
  74. WordPress 3.6, searchform.php problems
  75. Search in non-English language returns only one result
  76. Complex Search functionality. Advice needed
  77. Query Custom Meta Value with Increment
  78. How do I create a meta box for dates?
  79. Search and replace text across all posts
  80. Get user role by using user_id in buddypress
  81. How to use next_post_link and previous_post_link on single posts in search results
  82. Why is there a class=”screen-reader-text” on my search button?
  83. template_include for search.php makes WordPress think its on the home page
  84. Turning Broken URLs Into Search Terms?
  85. How can I implement faceted search with WordPress 3.x?
  86. can’t limit search to only pages
  87. Add custom parameters to JSON API search query?
  88. Combining Meta_Query key values for one array
  89. WPDB Multiple site’s posts and get featured images
  90. Change the Search Base in a multi language wordpress
  91. Display posts from an author using search parameters (not author template/query_posts)
  92. Search everything (posts, pages, tags, cpt, meta)
  93. Search: Only One Result Returned
  94. Search Terms – Querying on either description__like OR name__like in the same Term Query?
  95. How to find objects by terms
  96. Include custom table into search results
  97. Fulltext search in posts sorted by relevancy
  98. How to create a WP_Query to search the Title or Tag?
  99. How to redirect search result page to post
  100. Create multiple Search functions for posts / custom post types and everything
Categories search Tags post-meta, query, search
Hotel reservation plugin you would recommend [closed]
Set a default page template to load for multi-site

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