How can I query for posts using a date stored in post-meta?
I’m working on a games release feature for a website I’m building. So far everything is going smooth, but I’m stuck on one area. For the listings on the front end, I want it to look at the “release_date” field and only display games that have a release date = that date.
I feel the code below should work, but it doesn’t return/display anything on the front end. And if I switch it to =, it displays everything.
Any help would be greatly appreciated! Below is the query code.
$releasewindow = date('M j, Y', strtotime(-31 days));
$q = new WP_Query(array(
'post_type' = 'game_release',
'posts_per_page' = 5,
'meta_key' = 'release_date',
'orderby' = 'release_date',
'order' = 'ASC',
'meta_query' = array(
array(
'key' = 'release_date',
'compare' = '=',
'value' = $releasewindow,
)
),
Topic meta-query post-meta Wordpress
Category Web