It is not clear what you’re using as a comparison, but WP Query
supports meta query comparisons and even has a DATE type.
For example:
$query = new WP_Query( array(
'post_type' => 'attraction',
'meta_key' => 'attraction_date',
'meta_value' => '10',
'meta_compare' => 'LIKE',
'type' => 'DATE' ) );
Using 10
is not going to get you very far, you should use a timestamp.
I have not tested the date parameter in WP QUERY, it should be using/converting all dates to a unix timestamp using strtotime
, if not I would suggest doing so.
http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
http://php.net/manual/en/function.strtotime.php
Related Posts:
- Order by custom field date with ASC order
- Ordering posts by anniversary using only day and month
- Order RSS content by an advanced custom field value
- Alter main archive, to show posts with meta as last
- Ordering posts by custom field named “date” in backend
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- Order a query by meta_value and then by post_date
- Complex WP_Query Using Post Date And Post Meta
- Is there any action filter/hook for validating a custom field before publishing the post?
- ORDER BY custom field value
- Filter WP_Query for posts having a certain meta-value
- How to rename a custom field?
- Apply the_content filter to a custom field with multiple values
- How can I make wp-pagenavi work on a custom query built upon a form submission? [closed]
- Meta Query with AND & OR?
- Pass all custom fields through the same filter on post load?
- Query posts from current year
- Trying to perform complex custom field query with order by set to field value
- Order Posts by Closest Numeric Values
- Change content before writing to database
- WordPress Search Custom Meta Field Only
- Order Custom post type loop by custom field (datepicker)
- Order by Custom Field date not recognized
- Using custom fields in a filter hook
- Localized Date Format for Custom Field
- Add an advert every nth Paragraph
- How can I query on the year part of a complete date in a custom field?
- Plugin similar to Taxonomy Drill-Down for custom fields?
- Saving custom profile fields
- Sorting posts by custom fields in meta_query
- Count how many posts have a custom field set
- Only display posts after current date
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Update posts after populating ACF field value [closed]
- sort search results by custom fields using dropdown
- How to validate custom field on lost password form before the user id field?
- Conditional custom field query
- Display only past events on that page using Visual Composer Grid Bulider
- Create Pop-Up Box with Custom Field Content Inside the Loop
- global function to apply filter to custom field
- query usermeta from custom field
- How to order posts by one custom field and filter them by another one?
- Is there any way to get all meta and standard columns for any WordPress object after searching based on meta key and value
- Trying to sort and display categories(not posts) by custom field: ‘order’
- Change order of posts
- Trying to reorder posts by custom field
- Limits, not all post are showen when querying for posts by view count
- Meta query with multiple custom fields for archives page ordering problem
- query posts custom field calculation value
- WP Query – Is this correct?
- How to Wrote Simple Calculations by Using Custom Fields in Loop?
- Get post ids sorted by meta_key
- Using abs() with custom field in orderby statement
- pre_get_posts : only get posts by wp_usermeta value
- Best filter to use for modifying custom fields on a post?
- How to display childrens custom fields?
- List custom queried terms in the edit-tags.php?taxonomy page
- Get users based on month ACF datepicker field
- Access ACF fields within custom preview function?
- Sortable Custom Columns not sorting correct
- Sort posts by clicks on download button
- Loop through incrementing custom fields
- Order custom fields alphabetically
- Custom Theme Fields in Settings Menu – apply filters to one of those fields?
- How to change order of posts in admin
- How to query for posts with either one or another custom field
- How show post only from after custom date
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Get array of posts based on custom field values
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- Problem with writting correctly a query posts args in WordPress
- Filter or order based on custom field
- Custom Field Date Problem
- Compare ACF date field (if exists) and post date and order DESC
- How to show ACF fields in Gridbuilder custom block
- Problem with revisions only returning four results
- Dynamically populate query source in Elementor post widget
- Ordering by ACF custom field vaule
- User Filter Options on Archive Page
- searching by keywords in post’s metas or pagination links problem
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- How to properly get popular Posts by multiple Values
- Thirtieth century date for a post
- Filter and display a specific custom field value [closed]
- Query Posts Via WordPress URL
- query specific posts according their custom fields, using sql SELECT
- Meta_query not filtering posts
- Get multiple posts with some custom fields efficient
- How to add a prefix to existing custom fields over MYSQL query?
- Checking if field is set before comparing with meta_query in query_posts?
- Display posts where date field matches current month?
- How to check if custom field exists in this widget query
- Only show content slideshow if “slideshow” custom field exists
- Including inline Custom Fields info with add_filter in functions.php
- Sort posts after filtering them through multiple taxonomies
- Can’t sort custom column on user.php by number / meta_value_num?
- Get posts that were most recently tagged
- Dynamically update Custom Fields to display new dates
- Set new url from custom post field