有時候想知道本身WordPress博客的文章被點擊或瀏覽了多少次,而後對其進行熱門文章排行推薦給讀者,但據博客吧所知WordPress默認並無這個功能,因此須要用到WordPress博客插件來實現,博客吧推薦使用的瀏覽數量統計的插件是很是受歡迎的WP-PostViews插件。php
WP-PostViews插件介紹:ide
該插件由 GaMerZ 開發,主要是實現單篇文章閱讀數量統計、顯示瀏覽數量最多文章排行、分類下瀏覽數量最多的文章排行等功能效果。wordpress
WP-PostViews插件安裝:函數
WP-PostViews插件使用一:工具
方法一post
方法二.net
在主題文件sidebar.php文件中的相應位位置添加代碼插件
1 2 3 |
<?php if (function_exists('get_most_viewed')): ?> <?php get_most_viewed(); ?> <?php endif; ?> |
1 2 3 |
<?php if (function_exists('get_most_viewed')): ?> <?php get_most_viewed('post'); ?> <?php endif; ?> |
1 2 3 |
<?php if (function_exists('get_most_viewed')): ?> <?php get_most_viewed('post',10); ?> <?php endif; ?> |
在get_most_viewed 函數中的參數10決定要顯示的篇數3d
1 2 3 |
<?php if (function_exists('get_most_viewed_category')): ?> <?php get_most_viewed_category(the_catagory_ID(false)); ?> <?php endif; ?> |
在get_most_viewed_category函數類別ID決定顯示的分類blog
1 2 3 |
<?php if (function_exists('get_most_viewed_category')): ?> <?php get_most_viewed_category($cat,'post',5); ?> <?php endif; ?> |
在get_most_viewed_category函數類別ID決定顯示的分類
1 2 3 |
<?php if (function_exists('get_most_viewed_category')): ?> <?php get_most_viewed_tag($tag_id,'post',5); ?> <?php endif; ?> |
WP-PostViews插件使用二:
在文章中顯示該文章的瀏覽數量
1 |
<?php if(function_exists('the_views')) { the_views(); } ?> |
提示:文章中顯示的「熱度」可根據本身的想法創新!