People who run blogs, and people who enjoy earning money online usually love statistics. I know, personally, that I check my keywords, traffic and revenue streams a couple times a day. I make sure that I know exactly which keywords and threads people are interested in, so that I can work my future posts around them. On top of this, people are like sheep, they follow what others do. If there is a post which has many comments on it, the chances are, other people will show interest to this thread rather than another thread.

Displaying the number of times a thread has been read, is a useful way to control the traffic coming to your website. This can be tied hand in hand with advert placement, and so much more.

In order to display the number of reads each of your articles has had is fairly straight forward, here is my example:

  • Download this plugin. Upload and activate it as per usual.
  • The next step is to create a table in your database, using the following code:

create table mostAccessed
(
postnumber int not null,
cntaccess int not null,
primary key(postnumber),
unique id(postnumber)
);

  • Open your single.php file and search for this code:
    • <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  • Directly under this code, add the following code:
    • <?php if ($id > 0) { add_count($id); } ?>
  • Now search for this code:
    • <?php the_title(); ?>
  • Directly underneath, add the following code:
    • <?php if (!( is_home() || is_page() )) { ?>
      <?php show_post_count($post->ID,
      $before=”This post has been viewed “,
      $after=”
      times since “); ?>
      <?php } ?>

That’s it! Follow these steps carefully. It is vital that you place the <?php if ($id > 0) { add_count($id); } ?> code in the single.php file and not in your index file. If you place the code in your index.php file, each time the page is loaded, each post will increase the read count, which is definitely not what we want. The second code snippet you deal with, can however be placed in your index.php file - this will show the reads per post in your home page for each article.

Good luck!