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
- WP_Query – Order results by meta value
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- 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?
- Sort posts by custom field numeric value using dropdown
- Query posts from current year
- Date, Time, and Timezones
- Filter results with custom field values and dropdown
- Archive sorting functions by custom fields (front-end)
- Trying to perform complex custom field query with order by set to field value
- Order Posts by Closest Numeric Values
- Is there a way to do multiple ordering on a multiple meta_query?
- Order by custom field date?
- Change content before writing to database
- WordPress Search Custom Meta Field Only
- Order Custom post type loop by custom field (datepicker)
- Sorting within nested queries / multiple meta keys
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- Order by Custom Field date not recognized
- Comments form custom fields order
- If value present, order posts by two consecutive custom fields
- 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?
- Displaying posts with only upcoming dates according their custom field date value
- How to filter a dd/mm/yyyy date from a custom field in a query
- Plugin similar to Taxonomy Drill-Down for custom fields?
- Sorting posts by multiple values, combined
- How do I query for a post by custom field?
- Force hide custom field metaboxes
- 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?
- How can I sort homepage by a meta value?
- Loop to display random posts only if a custom field matches category
- Conditional custom field query
- Display only past events on that page using Visual Composer Grid Bulider
- Custom Field Create Bulk via SQL Query
- Create Pop-Up Box with Custom Field Content Inside the Loop
- filtering custom post types via meta data drop down
- 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
- Order by empty custom field
- Filter multiple custom fields Values with Check boxes
- How to get categories with posts by custom field 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
- Why orderbyb meta_value_num won’t affect the generated SQL Query order?
- 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
- querying a custom field
- Using abs() with custom field in orderby statement
- pre_get_posts : only get posts by wp_usermeta value
- ORDER BY custom field value out of where clause
- Best filter to use for modifying custom fields on a post?
- How to display childrens custom fields?
- How to query an out put value?
- 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
- Modify date query by URL parameter using pre_get_posts and $_GET
- Convert all dates stored in custom field
- Loop through incrementing custom fields
- Custom search SQL Query to add custom field in result
- Let Users Filter Posts by Custom Fields
- The best way to collision check in WP
- Order custom fields alphabetically
- How to exclude custom fields from search queries?
- Custom Theme Fields in Settings Menu – apply filters to one of those fields?
- Footnotes in custom fields