Loading... 打开主题存放目录<code>**sidebar.php**</code> 在合适的位置放入以下代码: ```php <!--那年今日--> <?php $time = time(); $todayDate = date('m/d', $time); $db = Typecho_Db::get(); $prefix = $db->getPrefix(); $sql = "SELECT * FROM `{$prefix}contents` WHERE created < {$time} and FROM_UNIXTIME(created, '%m/%d') = '{$todayDate}' and type = 'post' and status = 'publish' and (password is NULL or password = '') LIMIT 10"; $result = $db->query($sql); $historyTodaylist = []; if ($result instanceof Traversable) { foreach ($result as $item) { $item = Typecho_Widget::widget('Widget_Abstract_Contents')->push($item); $historyTodaylist[] = array( "title" => htmlspecialchars($item['title']), "permalink" => $item['permalink'], "date" => $item['year'] . ' ' . $item['month'] . '/' . $item['day'] ); } } ?> <?php if (count($historyTodaylist) > 0) : ?> <section class="widget widget_categories wrapper-md clear"> <h5 class="widget-title m-t-none text-md"><?php _me("那年今日") ?></h5> <ul class="joe_aside__item-contain"> <?php foreach ($historyTodaylist as $item) : ?> <li class="item"> <div class="tail"></div> <div class="head"></div> <div class="desc"> <time datetime="<?php echo $item['date'] ?>"><?php echo $item['date'] ?></time> <a href="<?php echo $item['permalink'] ?>" title="<?php echo $item['title'] ?>"> <?php echo $item['title'] ?> </a> </div> </li> <?php endforeach; ?> </ul> </section> <?php endif; ?> ``` 最后修改:2022 年 04 月 10 日 © 允许规范转载 赞 3 如果觉得我的文章对你有用,请随意赞赏
此处评论已关闭