WordPress: How to Install Post View Count/Top 10 Plugin

March 24, 2005 by  
Filed under PHP, Scripts and Coding, Wordpress

I just installed this Top 10 Posts/Views Plugin by Laughing Lizard. It did take a little poking around to figure out what goes where. With the new addition of themes in WordPress 1.5, adding plugins now requires you to edit each theme. So far, I’ve only edited the default one. I’ll edit the other themes later, but I’m feeling lazy right now. ;)

If you do decide to install this plugin, here’s a tip. Read all the comments on this post, especially what Kilikina posted. Well, you can do that, or read this post which takes you step by step on how to install the plugin. I figured out what needed to go where thanks to Kilikina!

Here are the instructions on how to install the plugin for the default Kubrick theme:

  1. First add the new table using phpmyadmin
    create table mostAccessed
    (
    postnumber int not null,
    cntaccess int not null,
    primary key(postnumber),
    unique id(postnumber)
    );
  2. Open up the top10.php plugin file in notepad or some text editor. Change the two occurances of $p to $id. It should be only this line:
    <?php if ($p > 0) { add_count($p);}?>
    change to:
    <?php if ($id > 0) { add_count($id);}?>
  3. Upload top10.php into your plugin directory and activate it. (You should be familiar with this step if you installed other plugins. If not, please view this.
  4. In the “Post Template” file (single.php), add

    <?php if ($id > 0) { add_count($id);} ?>
    <ul><?php show_pop_posts(); ?></ul>

    Just before:

    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?></p>
  5. In the “Main Template” (index.php) of your theme, find:
    <?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>

    And add this line right below it:

    <?php show_post_count($post->ID, $before="(Visited ", $after=" times)"); ?>
  6. I hope this helps. I know I’ll be referring back to it later on. ;)

Related Posts Plugin for WordPress, Blogger...
  • http://www.kilikina.net kilikina

    :)

  • http://www.kilikina.net kilikina

    :)

  • http://www.bleakgeek.com Jonathan

    Thank you. I actually ported over the plugin, but had some trouble finishing part of it. When I find time this weekend, I will update the plugin with the correct coding and documentation. Thank you for helping me fix these problems.

  • http://www.bleakgeek.com Jonathan

    Thank you. I actually ported over the plugin, but had some trouble finishing part of it. When I find time this weekend, I will update the plugin with the correct coding and documentation. Thank you for helping me fix these problems.

  • http://www.bleakgeek.com Jonathan

    Did you have any problems with show_pop_posts though? Mine turns out like this… http://www.bleakgeek.com/top10 and I can’t get it to show the permalink address’ to…

  • http://www.bleakgeek.com Jonathan

    Did you have any problems with show_pop_posts though? Mine turns out like this… http://www.bleakgeek.com/top10 and I can’t get it to show the permalink address’ to…

  • http://daynah.net daynah

    hmm how weird, mine worked fine. (See titles below this comment.) I just installed it on another website. But then again, I’m not using permalinks. I think that may be the problem…

  • http://daynah.net daynah

    hmm how weird, mine worked fine. (See titles below this comment.) I just installed it on another website. But then again, I’m not using permalinks. I think that may be the problem…

  • http://www.bleakgeek.com Jonathan

    Yeah, it’s really weird. It should still be working, just with ?p=….so I’m not sure what is going on with it at all.

  • http://www.bleakgeek.com Jonathan

    Yeah, it’s really weird. It should still be working, just with ?p=….so I’m not sure what is going on with it at all.

  • http://www.bleakgeek.com Jonathan

    I just remembered that there is the code for permalinks in it whoops…just gotta fix it up now hehe.

  • http://www.bleakgeek.com Jonathan

    I just remembered that there is the code for permalinks in it whoops…just gotta fix it up now hehe.

  • http://www.bleakgeek.com Jonathan
  • http://www.bleakgeek.com Jonathan