Exclude posts from wp_query based on meta_value
-
Hi –
I’ve setup a custom post type for events with custom fields added to it (one specifically being event date).
I’ve successfully queried the posts and sorted by the event date. My next goal is to exclude posts with an event date of at least yesterday.
Here is my code for the query:
<?php $upcoming_events = new WP_Query(array('post_type' => 'event', 'posts_per_page' => 4, 'order_by' => 'meta_value', 'meta_key' => '_refactord-datepicker', 'order' => 'ASC')); while ( $upcoming_events->have_posts() ) : $upcoming_events->the_post(); ?>
The event date being called by
_refactord-datepicker
Can someone please point me in the right direction for accomplishing my goal? The reason I’ve setup my custom event type rather than using a plugin is because the events need to have options turned on and off like Bottle Service Sign Up, Guest List, etc.
Thanks in advance!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Exclude posts from wp_query based on meta_value’ is closed to new replies.