Number of wordpress articles in a certain period of time

Source: Internet
Author: User
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.

  1. Function num_posts ($ days = 1) {// $ days indicates a day;
  2. Global $ wpdb;
  3. $ Today = gmdate ('Y-m-d H: I: S', time () + 3600*8); // Obtain the current time
  4. $ Daysago = date ("Y-m-d H: I: s", strtotime ($ today)-($ days * 24*60*60 )); // Today-$ days
  5. $ 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 ");
  6. Foreach ($ result as $ Item ){
  7. $ Post_ID [] = $ Item-> ID; // The published article ID, which is written into an array.
  8. }
  9. $ Post_num = count ($ post_ID); // number of elements in the output array, number of article IDs, that is, number of published articles
  10. $ Output. = ''. $ post_num.''; // Number of output articles
  11. Echo $ output;
  12. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.