Reputation: 69
Can someone show me how to do this, I have a query I'm using to display custom posts and using WP Facet for the query, by a custom field date, I got this far to order the posts by date in Ascending order, but the last thing I want to do is only show the posts that equal today's date or future dates;
I've tried a few things but no joy as of yet, thanks
<?php
return array(
'post_type' => 'event',
'post_status' => 'publish',
'posts_per_page' => 15,
'orderby' => 'event_date',
'order' => 'ASC',
'sort_custom' => true,
'meta_query' => array(
array(
'key' => 'event_date',
),
)
Upvotes: 0
Views: 43
Reputation: 69
if this helps anyone - i worked it out:
<?php
return array(
'post_type' => 'event',
'post_status' => 'publish',
'meta_key' => 'event_date',
'posts_per_page' => 15,
'orderby' => 'event_date',
'order' => 'ASC',
'sort_custom' => true,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'event_date',
'compare' => '>=',
'value' => date("Y-m-d"),
'type' => 'DATE'
),
)
);
Upvotes: 1