Good Morning,
I am currently trying to get a fooevents product that is closest to todays date, and of a certain product category. I'm using the following code:
$lastposts = get_posts(array(
'post_type'=>'product',
'posts_per_page' => 1,
'numberposts' => 1,
'tax_query' => array(
array('taxonomy' => 'product_cat','field' => 'slug', 'terms' => 'standard-ferry-service' )
),
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'WooCommerceEventsDate',
'meta_type' => 'DATE',
'meta_query' => array(
array(
'key' => 'WooCommerceEventsDate',
'compare' => '>=',
'value' => date('F d, Y'),
'meta_type' => 'DATE',
)
)
));
However this is seemingly pulling through a random product/event. Can anybody see if i have written anything wrong? The pull through of only the category items is fine, it's just not getting the right one.
Many thanks in advance for any help or advice.
date("Y-m-d")
instead ofdate('F d, Y')
and let me know if that solve the issue – kashalo Oct 9 '18 at 10:07