Hi!请登陆

typecho博客统计信息调用代码

2020-11-10 67 11/10

以下代码实现的功能是在网站前端界面,调用整站的文章总数、分类总数、评论总数以及页面总数量显示在指定位置,操作简单,直接把代码复制使用即可,当然显示样式需要自行编写。

统计代码:
1
2
3
4
5
6
7
8
9
10
<?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>

把上面的代码添加到当前使用主题的模板文件即可。

相关推荐