Is it possible via Query Block to create a query to select posts posted between 2 dates?
I didn’t found how to do but it would be very practical for me not to have to use Code Block.
PS: the dates are calculated from TODAY through TODAY + 3months
Is it possible via Query Block to create a query to select posts posted between 2 dates?
I didn’t found how to do but it would be very practical for me not to have to use Code Block.
PS: the dates are calculated from TODAY through TODAY + 3months
Hi @weedor,
Yes it is possible to do so (through the Date Query parameter), but if dynamic you’ll have to provide a YEAR, MONTH and DAY property which might not be ideal.
This may be a good place to add a general dynamic option for before and after properties so that full dates can be used instead of having to specify the detail for each.
That would be great, because I tried the solution that you propose and it is uggly.
I keep on looking for a quick solution (perhaps using “On sale from” and “On sale till”).
One problem is the lackof dates in the comparator.
In the same time, I am looking deep in queries and that is a good training.
If I find a solution, I will post it in reply.
Oh is this for a meta value?
If so, you can use the Meta Query parameter with the meta_key you’re interested in and simply use a shortcode with an array of the dates you want.
Then specify type as DATE and compare as BETWEEN
I must analyse your answer.
It is complicated for me but I will try and I hope to success.
I will keep you in touch.
@Louis ,
I digged a bit into meta queries.
Isn’t it posible to had custom option in the value: functions wordpress (today, date, is_user_logged_in(), etc.) and/or a shortcode that returns a value
In my case, I would have a meta value to DATE (today).
The meta query would be:
'meta_query' =>
array (
0 =>
array (
'key' => my field date ACF,
'value' => date("Y-m-d H:i:s"),
'compare' => '<=',
'type' => 'DATE',
),
),
In the same spirit, none values could be picked from woocommerce (woocommerce is my center of attention for now but it could be values from others plugins).