【问题标题】:Wordpress: Add a filter for "todays posts" to wp_queryWordpress:将“今日帖子”的过滤器添加到 wp_query
【发布时间】:2013-03-22 20:38:05
【问题描述】:

我在此处运行此查询以在我的 wordpress 索引页面上打印帖子:

query_posts( $query_string . '&order=ASC' . '&post.status=future,publish' );

它为我提供状态为发布或未来的升序的帖子。现在我想添加一个过滤器,这个查询只显示今天的帖子。因此,在当前日期已发布的帖子。

你能帮我解决这个问题吗?我尝试了很多,但没有任何效果或改变任何东西,所以我希望你们能提供一些意见。

提前非常感谢!

【问题讨论】:

    标签: wordpress date filter


    【解决方案1】:

    可能是这样的:

    $today = getdate();
    $year=$today["year"];
    $month=$today["mon"];
    $day=$today["mday"];
    
    query_posts( $query_string.'order=ASC' . '&post.status=future,publish'.'&year='.$year.'&monthnum='.$month.'&day='.$day );
    

    【讨论】:

      猜你喜欢
      • 2016-04-16
      • 1970-01-01
      • 2017-06-12
      • 1970-01-01
      • 1970-01-01
      • 2012-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多