WordPress 获取一定天数内发表的文章

WordPress4966阅读模式

WordPress 获取一定天数内发表的文章代码:

  1. <?php
  2. function filter_where($where = '') {
  3. $where .= " AND post_date > '" . date('Y-m-d', strtotime('-60 days')) . "'";
  4. return $where;
  5. }
  6. add_filter('posts_where', 'filter_where');
  7. query_posts($query_string);
  8. ?>

默认是60天内的文章。

将代码添加到主循环的上面。

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
知更鸟
评论  4  访客  4
    • YIMEITU
      YIMEITU 0

      :razz: 文章写的不错。 :razz:

      • 云创系
        云创系 2

        下载按钮的广告怎么做

        • 中南疯
          中南疯 0

          文章看不到,鸟哥

          • PC在线云端
            PC在线云端 3

            如何调用一定天数内的热门文章或是调用一定数量的推荐文章?
            或是调用 自定义某星级的文章?

          匿名

          发表评论

          匿名网友
          :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

          拖动滑块以完成验证