If the website is updated frequently and has a lot of content, the statistics of the website, such as the total number of articles, the total number of views, etc., will usually be displayed on the front page of the zblog website. In addition to these, the statistics of the number of updated articles in the last 24 hours are also frequently seen. How should the data of the number of articles published by zblog in the last 24 hours be used? Only two pieces of code are required.
Put the following code into the theme's include.php file:
function qiteen_postNum(){ global $zbp; $nowtime = time(); $settime = 1*24*60*60; $gettime = $nowtime-$settime; $db = $zbp->db->sql->get(); $sql = $db->select('zbp_post')->where(array(array('=','log_Status','0'),array('>','log_PostTime',$gettime)))->sql; $array = $zbp->GetListType('Post', $sql); echo count($array); }
Add code where you want to call (such as the footer.php file):
{qiteen_postNum()}
Save the file, update the cache or recompile the theme in the background.
Note: The above code is only applicable to zblog php version 1.5 or above.