I haven’t had much success in the past using the BETWEEN
comparison with meta queries. You might have better luck by replacing your meta query with a >=
and <=
comparison:
'meta_query' => array(
array(
'key' => 'opening_time',
'value' => $today,
'compare' => '>=',
'type' => 'DATE'
),
array(
'key' => 'opening_time',
'value' => $future,
'compare' => '<=',
'type' => 'DATE'
)
)
Depending on your application you may want to tune the results a bit by dropping the “or equal to” from one or both of the statements (right now it’s being very forgiving).
As for the PHP error, the code you provided doesn’t end the “for” loop with an endfor
. Have you checked your PHP error log? You can also try turning on WP_DEBUG
in your wp-config.php file.
Related Posts:
- How to set a custom post type to have viewable future posts
- how to compare different timestamps in wp-query for events custom post types?
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Query events post type after current date and timezone
- Query Event Posts by Date
- Count of posts with meta_key filled in?
- Query all posts where a meta key does not exist
- Single loop for wp_query and wp_user_query
- query multiple taxonomies
- Custom Post Type, WP_Query and ‘orderby’
- Syntax to get the Nth item in a list of custom post types?
- Grab 5 latest posts from custom post type ‘announcements’
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Numeric pagination custom post type
- Using Query Posts With Multiple Post Types And A Taxonomy
- List with categories, subcategories and posts of custom posttype
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- sort events based on event date custom field
- Custom Taxonomy List links being re-written
- Can’t sort order of wp_query with 2 meta keys
- Want to filter only parent post in admin area
- Get count of custom post type created by current user
- Query Custom Post by Category
- Having trouble with custom date field for CPT query (WordPress)
- Quickest way to get last or oldest post date – WP Query
- Display posts if a custom field value is equal to another custom field value
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Custom post query by taxonomy
- CPT posts listed by category with custom rewrite URL, please help!
- Group custom posts by custom taxonomy names
- Using global $post; to get featured image for custom post via WP_Query
- Query custom post type by category slug
- Can’t query tag and post_type at the same time
- Wrong request query on cpt and tax
- Search / Filter posts on Title/Content OR Tags
- Converting the_content string to an array?
- Isotope Filtering with Bootstrap Tabs – Custom Post Type Query Loop in each Tab (Have to click twice to filter)
- Custom taxonomy rewrite give pagination 404
- creat filter with wp_query
- How to do WP_Query with two meta fields with orderby clause
- Get Posts by multiple custom fields is not working
- Custom query at top of archive search page, arguments are overridden
- How to display post list inside post
- Sort entries by date mixing two post types
- Advanced search form with filters for custom taxonomies
- custom post type search by reference id
- Showing specific post in order of array wp_query
- WP the_posts() on single-cars.php get category link
- tax_query not working in template
- Print current post category during WP_Query
- Multiple Custom Post Type queries, how to DRY it up
- Custom WP_Query always respond with 200 status even when no entry
- WPDB for post count on post
- post_per_page ignored in WP_Query
- Pagination 404 on Index with custom query
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- Cannot get custom post
- Custom post type and standard post not displaying or working
- Sort custom post type by most current date picker
- Display custom post type for specific user
- Get all post from a post type
- Trying to add a class to post links
- A faster way to query custom post types with multiple conditions?
- WP_Query: Posts within category OR custom post type
- Two queries – one with checkbox ticked, one without – comparing meta_query
- posts_per_page in custom WP_Query does not override “Reading” settings?
- WP Query from two Custom Post type fields as statement
- Display Parent-Child Posts in specific order by comparing IDs in array
- Apply category query clause to posts of custom type
- How to output custom post type title on custom page with category next to it?
- How to sort by multiple values in a nested WP_Query
- SEARCH QUERIES – REVERSE OUTPUT
- WP_Query to display number of custom post type filtered (order by) taxonomy
- 2 modal windows with ACF content on Archive page
- post_type incorrect for custom post type
- Live search by custom tag
- Custom Post Type – Display all, wrap in groups of 3
- Ajax load more inside custom post type taxonomy
- How to get the posts that my following users are liked?
- Only show categories that have posts within custom post type
- Create a custom wp_query from a specific custom post type with specific taxonomy
- SQL LIKE in WP_Query
- How can you use a page for a custom post type?
- Display all Custom taxonomy terms and their relevant custom posts
- CPT Efficient way to display posts from different categories with custom query
- How To Loop Through list with Custom Post Types
- CPT or Custom Table for Repository of Serial Numbers
- Query Pulling the same post twice
- Use Tags to Query Associated Multiple Posts and Get The Average Of Custom Field Values
- Custom Post Type + Category archive
- Values inside a custom field to determine which category posts to display
- How do I sort post listing by child post count?
- Pop up showing same content on all posts display.
- Custom post-type’s pagination not working in category.php
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Are custom posts included when getting a categories’ posts?
- Query order by meta value force specific tag first
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- How can I show posts with the same tag?
- Load posts via AJAX without draft status