Hey folks,
Returning to this question from before, I’ve got half the equation fixed but can’t figure out its flipside.
So, quick TL;DR — we wanted to display products with a ACF launch_date of today or later. With the query string builder, I was able to get that string firing perfect:
post_type=product&post_status=publish&orderby=meta_value&meta_key=launch_date&meta_query%5B0%5D%5Bkey%5D=launch_date&meta_query%5B0%5D%5Bcompare%5D=%3E%3D&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format="Ymd"}}&meta_query%5B0%5D%5Btype%5D=DATE&order=asc
My functions.php looks like this:
function get_query_string() {
$today = date( 'Ymd' );
$query = array(
'post_type' => 'product',
'post_status' => 'publish',
'orderby' => 'meta_value',
'meta_key' => 'launch_date',
'meta_query' => array(
array(
'key' => 'launch_date',
'compare' => '>=',
'value' => $today,
'type' => 'DATE',
)
),
'order' => 'asc'
);
var_dump( http_build_query( $query ) );
} add_action( 'wp_footer', 'get_query_string' );
Excellent.
But when I replace the compare value with ’ < ’ I should get all posts with launch_dates before Today… but my ouput is nothin’. (We want an archive of classes once offered.)
Here’s the query string:
post_type=product&post_status=publish&orderby=meta_value&meta_key=launch_date&meta_query%5B0%5D%5Bkey%5D=launch_date&meta_query%5B0%5D%5Bcompare%5D=%3C&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format="Ymd"}}&meta_query%5B0%5D%5Btype%5D=DATE&order=asc
Here’s the URL we’re working on: https://radiobootcamp.org/cornerstone/content/288
Credentials will be attached as a secure note