How to display the number of articles read in wordpress

Source: Internet
Author: User
After an article is published, how can we display the number of people who have browsed this article so that visitors can choose to browse the article? however, WordPress itself has no article reading counter, if you want to display the reading times of an article like zblog, you have to find a solution. However, we can use the plug-in to implement the plug-in & nbsp; WP-PostViews & nbsp; which can implement the side

After an article is published, how can we display the number of people who have browsed this article so that visitors can choose to browse the article? however, WordPress itself has no article reading counter, if you want to display the reading times of an article like zblog, you have to find a solution. But we can use the plug-in to implement what I used previously? WP-PostViews? Can this plug-in implement the sidebar? Widgets are powerful.

Usage:

1. easy installation, You only need to add the plug-in input in the background "? After WP-PostViews is installed, you can call the following code on the homepage (index. php) and content page (single. php) to display the browsing times.

 

The author finds the following code in these two files and adds the above code to the end

 

2. you can call the tool to display the most popular articles or pages on the sidebar.

3. code call

3.1 display the most frequently read articles or pages:

 
 
 

The Get_most_viewed () function contains two parameters.

The type of the first parameter is "article or page" or "both have", such as "post", "page", or "both ".

The second parameter is the number of list objects.

3.2 display the most frequently read articles in a category directory:

 
 
 

Get_most_viewed_category ()

There are three parameters in the brackets of the function.

The first parameter is the ID of the category directory.

The second parameter type is "article", "page", or "both", such as "post", "page", or "both ".

The third parameter is the number of list objects.

Example:

Get_most_viewed_category (5, 'both ', 10 );//? You can read up to 10 articles in the category directory with the ID of 5.

Related? Posts:

Wordpress statistics plugin: WP-PostViews? Plus? Syntax call

Browser count display template? :

% VIEW_COUNT % people

Which of the following is the most visited template? :

  • % POST_TITLE % (? % VIEW_COUNT % Times)
  • Robot? User_agent? :

    Bot? Spider? Slurp

    This is the background setting syntax.

    The following is the foreground outbound call syntax. you can adjust the parameters as needed.

    The_bot_views (null ,? True)

    In this article, the first parameter of the robot browser number is the instruction text added after the number to cancel this function, and the second parameter is set in the background to output (true is printed directly, and false is the return value)

    The_user_views (null ,? True)

    The first parameter of the user's browser in this article is the description text added after the number to cancel this function, and is changed to the background to set whether the second parameter is output (true is printed directly, false is the return value)

    The_views (null ,? True)

    The first parameter of the browser number in this article is the description text added after the number to cancel this function, and is changed to the background to set whether the second parameter is output (true is printed directly, false is the return value)

    Get_totalviews (true ,? True)

    Total number of views
    The first parameter is whether to output (if true, it is printed directly ,? Return value when false)
    Does the second parameter contain the number of views of the robot (true: Include ,? False is not included)

    Get_timespan_most_viewed_tag ?? (1 ,? Null ,? 10 ,? 0 ,? True ,? True ,? 7)

    The maximum number of articles read in a specified category is

  • And
  • List of surrounded projects
    The first parameter is a qualified Category ID (which can be an array composed of category IDs)
    The type of the second parameter article ('post' is the article 'page' is pagination "is required for both)
    The third parameter is the number of output articles.
    The fourth parameter is the number of words in the document title (0 is unlimited)
    The fifth parameter indicates whether to output the data. (if true, the data is printed directly ,? Return value when false)
    The sixth parameter is whether the robot's viewing quantity is included (true is included ,? False is not included)
    The seventh parameter is the last days of the query.

    Get_timespan_most_viewed_category (1 ,? Null ,? 10 ,? 0 ,? True ,? True ,? 7)

    The maximum number of articles read in a specified category is

  • And
  • List of surrounded projects
    The first parameter is a qualified Category ID (which can be an array composed of category IDs)
    The type of the second parameter article ('post' is the article 'page' is pagination "is required for both)
    The third parameter is the number of output articles.
    The fourth parameter is the number of words in the document title (0 is unlimited)
    The fifth parameter indicates whether to output the data. (if true, the data is printed directly ,? Return value when false)
    The sixth parameter is whether the robot's viewing quantity is included (true is included ,? False is not included)
    The seventh parameter is the last days of the query.

    Get_timespan_most_viewed (",? 10 ,? 0 ?,? True ?,? True ,? 7)

    The maximum number of articles to be viewed is

  • And
  • List of surrounded projects
    The first parameter is the type of the query article ('post' is the article 'page' is paging "is required for both)
    The second parameter outputs the number of articles returned.
    The third parameter is the number of words in the document title (0 is unlimited)
    The fourth parameter is whether to output (if true, it is printed directly ,? Return string if false)
    The fifth parameter is whether the robot's viewing quantity is included (true is included ,? False is not included)
    The sixth parameter is the last days of the query.

    Get_most_viewed_tag ?? (1 ,? Null ,? 10 ,? 0 ,? True ,? True)

    The maximum number of articles read in a specified category is

  • And
  • List of surrounded projects
    The first parameter is a qualified Category ID (which can be an array composed of category IDs)
    The type of the second parameter article ('post' is the article 'page' is pagination "is required for both)
    The third parameter is the number of articles returned by the output. The fourth parameter is the number of words in the article title (0 is unlimited)
    The fifth parameter indicates whether to output the data. (if true, the data is printed directly ,? Return value when false)
    The sixth parameter is whether the robot's viewing quantity is included (true is included ,? False is not included)

    Get_most_viewed (",? 10 ,? 0 ?,? True ?,? True)

    The maximum number of articles to be viewed is

  • And
  • List of surrounded projects
    The first parameter is the type of the query article ('post' is the article 'page' is paging "is required for both)
    The second parameter outputs the number of articles returned.
    The third parameter is the number of words in the document title (0 is unlimited)
    The fourth parameter is whether to output (if true, it is printed directly ,? Return string if false)
    The fifth parameter is whether the robot's viewing quantity is included (true is included ,? False is not included)

    Get_most_viewed_category (1 ,? Null ,? 10 ,? 0 ,? True ,? True)

    The maximum number of articles read in a specified category is

  • And
  • List of surrounded projects
    The first parameter is a qualified Category ID (which can be an array composed of category IDs)
    The type of the second parameter article ('post' is the article 'page' is pagination "is required for both)
    The third parameter is the number of articles returned by the output. The fourth parameter is the number of words in the article title (0 is unlimited)
    The fifth parameter indicates whether to output the data. (if true, the data is printed directly ,? Return value when false)
    The sixth parameter is whether the robot's viewing quantity is included (true is included ,? False is not included)

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.