您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

wordpress某段时间内的文章数

2025/7/4 18:41:53发布18次查看
wordpress某段时间内的文章数,具体效果可以到无冷博客查看 function num_posts($days=1) {//$days就是设定时间一天; global $wpdb; $today = gmdate('y-m-d h:i:s', time() + 3600 * 8);//获取当前的时间 $daysago = date( y-m-d h:i:s, strtotime($today) - ($days * 24 * 60 * 60) ); //today - $days $result = $wpdb->get_results(select id from $wpdb->posts where post_date between '$daysago' and '$today' and post_status='publish' and post_type='post' order by post_date desc ); foreach ($result as $item) { $post_id[] = $item->id;//已发布的文章id,写到一个数组里面去 } $post_num = count($post_id);//输出数组中元素个数,文章id的数量,也就是发表的文章数量 $output .= ''.$post_num.'';//输出文章数量 echo $output;}
复制代码
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product