WordPress 博客文章瀏覽數統計插件WP-PostViews

有時候想知道本身WordPress博客的文章被點擊或瀏覽了多少次,而後對其進行熱門文章排行推薦給讀者,但據博客吧所知WordPress默認並無這個功能,因此須要用到WordPress博客插件來實現,博客吧推薦使用的瀏覽數量統計的插件是很是受歡迎的WP-PostViews插件。php

WP-PostViews插件介紹:ide

該插件由 GaMerZ 開發,主要是實現單篇文章閱讀數量統計、顯示瀏覽數量最多文章排行、分類下瀏覽數量最多的文章排行等功能效果。wordpress

WP-PostViews插件安裝:函數

  1. 下載WP-PostViews插件,並上傳至wp-content/plugins/目錄下
  2. 登錄博客後臺,啓用該插件,這時設置選項卡下會生成一個PostViews選項和小工具中會生成一個Views工具

WP-PostViews插件使用一:工具

  • 點擊設置選項卡下的PostsViews選項進入插件設置界面

    Count Views From:設置被統計的用戶羣
    Everyone:全部人
    Guests only:僅訪客
    Registered Users Only:僅註冊用戶
    Exclude Bot Views:是否排除機器人的瀏覽
    YES:是
    NO:不是
    Views Template:瀏覽量的顯示格式,默認是:%VIEW_COUNT% views ,博客吧的是「熱度%VIEW_COUNT% 度」,隨時可點擊「Restore Default Template」恢復默認設置。
    Most Viewed Template:側邊欄 Widget 顯示瀏覽量最多的文章(亦稱「最受歡迎文章」)列表時的顯示格式。可用%VIEW_COUNT%、 %POST_TITLE%、%POST_EXCERPT%、%POST_CONTENT%、%POST_URL%對其進行參數設置
    Display Options:顯示設置
    Home Page(首頁)、Singe Posts(文章頁)、Pages(頁面)、Archive Pages(分類歸檔頁)、Search Pages(搜索頁)、Other Pages(其它頁面),可進行Display to everyone(全部人)、Display to registered users only(註冊用戶)、Don’t display on ***(不顯示在***)

方法一post

  • 在當前WordPress博客主題支持widget(小工具)前提下,在可用小工具中把Views小工具放到相應位置便可。

    Statistics Type
    least viewed:瀏覽最少的文章
    least viewed by category:該分類下瀏覽最少的文章
    most viewed:瀏覽最多的文章
    most viewed by category:該分類下瀏覽最多的文章
    Include Views From
    posts & pages:顯示文章和頁面
    posts only:只顯示文章
    pages only:只顯示頁面

方法二.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; ?>
  • 只想顯示10篇閱讀次數最多的文章:
    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決定顯示的分類

  • 顯示當前Tag頁面下的閱讀次數最多的文章:
    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. 點擊外觀選項卡下的編輯選項進入主題編輯界面,選擇主題文件single.php文件進行編輯
  2. 在single.php文件相應位置調用顯示代碼
    1
    <?php if(function_exists('the_views')) { the_views(); } ?>
  3. 提交更新文件便可

提示:文章中顯示的「熱度」可根據本身的想法創新!

相關文章
相關標籤/搜索