FacetWP,从今天开始查询

时间:2019-10-21 16:05:15

标签: wordpress

我正在寻找一种查询日期为今天(当前日期)的帖子的方法。

我的查询如下:

<?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"
];

我不知道要在TYPE和VALUE上设置什么。 这可以帮我吗? 非常感谢。

1 个答案:

答案 0 :(得分:0)

实际上我发现了如何做:)

这是我应该使用的摘录:

<?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"
];