I've been writing this blog for almost two months, and recently I wanted to see how many page views I've gained during this period. That reminded me of a site statistics widget. This widget is not integrated into the theme by default, so you need to add it yourself. If you know PHP, you can integrate it directly into the theme.

Here is a screenshot of how it looks on this site for your reference. You can also modify or replace the CSS styles yourself.

Code

<ul class="site-profile">
<li><i class="fa fa-file-o"></i> 文章总数:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?></li>
<li><i class="fa fa-commenting-o"></i> 留言数量:<?php global $wpdb; echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments"); ?></li>
<li><i class="fa fa-folder-o"></i> 分类数量:<?php echo $count_categories = wp_count_terms('category'); ?></li>
<li><i class="fa fa-tags"></i> 标签总数:<?php echo $count_tags = wp_count_terms('post_tag'); ?></li>
<li><i class="fa fa-link"></i> 链接数量:<?php global $wpdb; echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); ?></li>
<li><i class="fa fa-clock-o"></i> 运行时间:<?php echo floor((time() - strtotime("2007-8-1")) / 86400); ?></li>
<li><i class="fa fa-eye"></i> 浏览总量:<?php echo all_view(); ?></li>
<li><i class="fa fa-pencil-square-o"></i> 最后更新:<?php global $wpdb; $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')"); $last = date('Y年n月j日', strtotime($last[0]->MAX_m)); echo $last; ?></li>
</ul>

Notes

  1. Font Awesome icon library
    The code uses icons from the Font Awesome icon library. If the theme has already configured Font Awesome, the icons can be displayed directly. If the theme has not configured it, you can install the Font Awesome 4 Menus plugin to solve this.
  2. The text box supports PHP
    When adding the widget, make sure that the text box supports parsing PHP code so that the code above can work properly.