资料来源:云烟博客 - 解决Typecho新文章、页面uid排序错乱问题注意事项:请在PHP7以上版本的服务器上执行。本操作涉及数据库,请提前做好备份工作。解决cid排序错乱问题:将下面的两段代码分别放入网站根目录后进行访问<?php /** * Typecho重新排列分文章cid让他连续 */ <?php // 设置数据库参数 $hostname_blog = "localhost"; $database_blog = "数据库名"; $username_blog = "数据库用户名"; $password_bl...

资料来源:老蒋部落 - 利用代码实现统计Typecho文章的阅读浏览次数添加以下代码到当前使用的typecho主题的functions.php文件中:function get_post_view($archive){ $cid = $archive->cid; $db = Typecho_Db::get(); $prefix = $db->getPrefix(); if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) { $db->qu...

将以下代码加入functions.php,/*人性化时间*/ function human_time_diff($from, $to = '') { if (empty($to)) { $to = time(); } $diff = abs($to - $from); $year_diff = floor($diff / (365.25 * 86400)); // 平均每年 365.25 天 if ($year_diff >= 1) { if ($year_diff == 1) { re...

资料来源:Typecho.dev - Typecho教程:在页面输出加载时间在主题 functions.php 文件里放入下面代码/** * 加载时间 * @return bool */ function timer_start() { global $timestart; $mtime = explode( ' ', microtime() ); $timestart = $mtime[1] + $mtime[0]; return true; } timer_start(); function timer_stop( $display = ...

资料来源:王叨叨 - Typecho前台添加编辑文章链接在文章内页增加编辑标签链接,在登录后直接对文章进行编辑,而无须繁琐操作:<?php if($this->user->hasLogin()):?> <?php if($this->user->pass('administrator','true')):?> <a href="/admin/write-post.php?cid=<?php echo $this->cid;?>" target="_blank">...