Number of wordpress articles in a certain period of time
The number of articles in wordpress in a certain period of time. you can view the specific effect on a non-cold blog.
- Function num_posts ($ days = 1) {// $ days indicates a day;
- Global $ wpdb;
- $ Today = gmdate ('Y-m-d H: I: S', time () + 3600*8); // Obtain the current time
- $ 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; // The published article ID, which is written into an array.
- }
- $ Post_num = count ($ post_ID); // number of elements in the output array, number of article IDs, that is, number of published articles
- $ Output. = ''. $ post_num.''; // Number of output articles
- Echo $ output;
- }
|