王尘宇王尘宇

研究百度干SEO做推广变成一个被互联网搞的人

Typecho 24小时宣布文章数目

Typecho 24小时宣布文章数目


在functions.php代码文件内里增加以下代码:

function get_recent_posts_number($days = 1,$display = true){        $db = Typecho_Db::get();        $today = time() + 3600 * 8;        $daysago = $today - ($days  24  60 * 60);        $total_posts = $db->fetchObject($db->select(array('COUNT(cid)' => 'num'))              ->from('table.contents')              ->orWhere('created < ? AND created > ?', $today,$daysago)              ->where('type = ? AND status = ? AND password IS NULL', 'post', 'publish'))->num;        if($display) {            echo $total_posts;        } else {            return $total_posts;        }}

模板挪用代码:

<?php get_recent_posts_number(12); ?>

参数: 12是12天,改成1等于24小时内


相关文章

评论列表

发表评论:
验证码

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。