【问题标题】:wordpress - How to filter post by date,month and yearwordpress - 如何按日期、月份和年份过滤帖子
【发布时间】:2019-11-07 19:22:41
【问题描述】:

我创建了一个 WordPress 帖子过滤器页面。我想按日期、月份和年份过滤帖子。我该怎么做?

样本..

          's' => (!empty($_REQUEST["search"])?$_REQUEST["search"]:''),
          'post_type' => 'post',
          'post_status' =>'publish',
          'cat' => 5,
          'posts_per_page' => 9,
          'paged' => 1,
          (!empty($_GET["monthnum"])?'monthnum' =>$_GET["monthnum"]:false),
          (!empty($_GET["year"]))?'year' => $_GET["year"]:false),
          'orderby' =>!empty($_GET["orderby"])?$_GET["orderby"]:'date'
        );```

【问题讨论】:

    标签: wordpress filter


    【解决方案1】:

    在这种情况下,您可以使用以下参数来获取帖子:

    $args= array(
      'post_type' => 'post',
      'post_status' =>'publish',
      'cat' => 5,
      'posts_per_page'=> 9,
      'paged' => 1,
      'orderby'=>'post_date'
    );
    

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-14
      • 1970-01-01
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多