0

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

我的查询看起来像这样:

<?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 上设置什么。请问这可以帮助我吗?非常感谢。

4

1 回答 1

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

于 2019-10-21T20:07:17.773 回答