My code is as follows:
$posts = get_posts(array( 'post_type' => 'events', 'posts_per_page' => -1, 'meta_key' => 'from_datetime', 'meta_value' => date( "F d, Y g:i a" ), 'meta_compare' => '>', 'orderby' => 'meta_value', 'order' => 'ASC' ));
The custom fields are made using ACF in our blog. The
from_datetime field shows like this:
April 18, 2017 2:30 pm
So I've translated this to the date nomenclature:
date( "F d, Y g:i a" )
Events are a custom post type. Basically I want to show the upcoming 2 events that are NOT passed. So this is quite close to the example on the WP_Query page, but still the above doesn't work. The query returns nothing. I do know that if I remove the
meta_value stuff above, there are four events to show that are beyond "now".
Any thoughts on what I may be doing wrongly? The query seems correct according to the documentation at WP. Thank you!