typecho博客统计信息调用代码
以下代码实现的功能是在网站前端界面,调用整站的文章总数、分类总数、评论总数以及页面总数量显示在指定位置,操作简单,直接把代码复制使用即可,当然显示样式需要自行编写。
统计代码:
<?php if ($this->options->sidebarBlock && in_array('showSiteStatistics', $this->options->sidebarBlock)): ?> <section class="widget"> <h3><?php _e('数据统计'); ?></h3> <ul> <?php Typecho_Widget::widget('Widget_Stat')->to($stat); ?> <li><?php _e('文章数量:'); ?><?php $stat->publishedPostsNum() ?></li> <li><?php _e('分类数量:'); ?><?php $stat->categoriesNum() ?></li> <li><?php _e('评论数量:'); ?><?php $stat->publishedCommentsNum() ?></li> <li><?php _e('页面数量:'); ?><?php echo $stat->publishedPagesNum + $stat->publishedPostsNum; ?></li> </section>
把上面的代码添加到当前使用主题的模板文件即可。
看完你可能还喜欢
- 上一篇:Typecho自动删除冗余、空白字段
- 下一篇:Typecho 定时发表文章的方法