Reputation: 33
i'm looking for a way to query posts with a date from today (current day).
My query looks like that :
<?php
return [
"post_type" => [
"event"
],
"post_status" => [
"publish"
],
"meta_query" => [
"0" => [
"key" => "date",
"compare" => ">",
"type" => "DECIMAL(16,4)",
"value" => "XXXXX"
],
"sort_0" => [
"key" => "date",
"type" => "CHAR"
]
],
"orderby" => [
"sort_0" => "ASC"
],
"posts_per_page" => "4"
];
I don't know what to set on TYPE and VALUE. Is this possible to help me please? Thanks a lot.
Upvotes: 1
Views: 998
Reputation: 33
Actually I found out how to do it :)
Here is the snippet I should have used :
<?php
return [
"post_type" => [
"event"
],
"post_status" => [
"publish"
],
"meta_query" => [
"sort_0" => [
"key" => "date",
"compare" => ">",
"type" => "DATE",
"value" => date("Y-m-d"),
]
],
"orderby" => [
"sort_0" => "ASC"
],
"posts_per_page" => "4"
];
Upvotes: 1