Typecho博客统计信息调用代码

Typecho博客统计信息调用代码

Aaron
2022-04-18 / 0 评论 / 689 阅读 / 正在检测是否收录...

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

<?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>
        </ul>
    </section>

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

0

评论 (0)

取消