WordPress: How to Install Post View Count/Top 10 Plugin
March 24, 2005 by daynah
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:
- First add the new table using phpmyadmin
create table mostAccessed
(
postnumber int not null,
cntaccess int not null,
primary key(postnumber),
unique id(postnumber)
); - 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);}?> - 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.
-
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> - 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)"); ?>
I hope this helps. I know I’ll be referring back to it later on. ;)


@






