3/14/2005 ↓

Top 10 Posts/Views

Author: Jonathan Dingman Category: Wordpress Plugins

Thanks for visiting! We would like to serve you better. Please subscribe to our RSS feed for daily updates. This blog posts regular Wordpress news, updates of themes, plugins, ideas, hacks, quick fixes and everything about blogging, especially about Wordpress. You can also receive updates from this blog via email if you want that method of notification.

For quite some time now, Mark has had some PHP code snippets just hanging around here on the site. Feeling the need to create a plugin for it and cite the documentation a little better, I did so. You may now find the, once what was just code, plugin Top 10 Posts/Views.

This plugin functions as a means to showing your top 10 posts (sorted by number of views) and displaying the total number of views on a per post basis. I have seen many sites use this code and now it is a plugin for all to use.

Update on 04/08/05: I have updated this script with better documentation and easier use of the script. Please note the documentation in the script itself at the top and you may refer to this page I have created to show some examples of the code.

1 Star2 Stars3 Stars4 Stars5 Stars (57 votes, average: 4.11 out of 5)
Loading ... Loading ...

Friends

Translate

Translate to German Translate to Spanish Translate to French Translate to Italian Translate to Portuguese Translate to Japanese Translate to Korean Translate to Russian Translate to Chinese

Latest Videos

83 Comments | Comments closed | Comments RSS

  1. Ok, I’ve uploaded and activated the plugin, and am a little lost on what to do next. Any help is appreciated. Thanks. BTW, I noticed you linking to BrowseHappy.org, did you have anything to do with that site? I was one of the interviewees and my story is still there.

    [Reply] theMike (3 comments.) — 03/15/2005 @ 1:17 am
  2. If you view the actual plugin, it has instructions in the file itself. I may re-upload the file with 2 files. So just download it again and view it to see how to use it.

    [Reply] Jonathan (12 comments.) — 03/15/2005 @ 3:29 am
  3. It really a plugin what I want!!

    I use the pool Theme,and i can’t find this code in my index.php

    How to?

    [Reply] bingu — 03/15/2005 @ 3:54 am
  4. I can’t get it to work either. I’m using 1.5 and basically copied the default theme over to the theme directory that the install created, and used my stylesheet from 1.2

    I’m guessing the line:
    0) { add_count($p);}?> goes into single.php but nothing posts to the mostAccessed table. I’ve tried moving the line to about 4 or 5 different places and still nothing happened :(

    [Reply] kilikina (5 comments.) — 03/15/2005 @ 4:33 am
  5. hrmm… ok after fiddling for a little I found where it goes. In the default wp 1.5 template it would go right before the line that says:

    the only problem now is with permalinks the url isn’t calling ?p=postnumber so the postnumber is passing as 0. the statement checks for that so nothing goes to the database =\

    If i go to mydomain.com/?p=399
    it works

    If i go to mydomain.com/archives/2005/03/13/postname/
    it doesnt work :(

    Is there any way to fix that?

    [Reply] kilikina (5 comments.) — 03/15/2005 @ 4:44 am
  6. I got it :P
    replaced $p with $id and it worked

    [Reply] kilikina (5 comments.) — 03/15/2005 @ 5:01 am
  7. Hi

    I also have some problems with this one, first I cannot find the line you are refering to, I added it inside the loop but it does not seem to add any data to the db. When running the webpage I get an error

    Warning: Invalid argument supplied for
    foreach() in …\plugins\top10.php on line 67

    Thanks for any help.

    [Reply] Jens (6 comments.) — 03/15/2005 @ 5:41 am
  8. Sorry about the mix-up then. I’ll make an update to it with corrections. It works fine under my other blogs, not sure why it’s not working here. Thanks for reporting it.

    [Reply] Jonathan (12 comments.) — 03/15/2005 @ 5:45 am
  9. Jonathan: Thanks
    kilikina: On what line did you put it?

    [Reply] Jens (6 comments.) — 03/15/2005 @ 5:46 am
  10. oh lol… guess it got funked up by the php tags =\
    it goes in single.php right on top of :

    <?php endwhile; else: ?>

    <p> <?php _e(’Sorry, no posts matched your criteria.’); ?> </p>

    [Reply] kilikina (5 comments.) — 03/15/2005 @ 10:29 am
  11. I just got it working from this plugin, having used the hack for a while.
    Couple of issues:

    Compare what I have below with what is in the plugin and make the changes. This preserves code validity.

    //$url = get_permalink($post->ID);
    echo “<li><a href=”$siteurl”.”index.php?p=”.$post->ID.”&more=1&c=1″ title=”$text”
    >$post_title</a>  <strong>($result->cntaccess)</strong></li>”;
    }
    }

    [Reply] Podz — 03/15/2005 @ 1:50 pm
  12. Hi, I now got it up & running, working great after the help from Podz.I do have a request. Could it be possible to write out the url rewrite urls instead of the p=x version somehow? It is just because of my stats, it will now as it is look like two different urls.

    Is it possible?

    Here is how it looks now http://jedisthlm.com/

    And thanks again for a great plugin.

    [Reply] Jens (6 comments.) — 03/16/2005 @ 10:33 am
  13. I will try to make the update today with those things. I’m not sure if I will be able to make it using the permalinks instead, but I’ll see what I can do.

    [Reply] Jonathan (12 comments.) — 03/16/2005 @ 8:16 pm
  14. Top 10 Posts/Views

    自己成功装了第一个(以前安装过一些,没成功0_o!!)wordpress plugin-Top 10 Posts/Views,其实,WordPressçš„Plugin是很容易安装的,只要把Pluin放到特定的目录下,在后台激活就搞定的了.但这个Plugin需要改…

    冰古Blog — 03/17/2005 @ 11:42 am
  15. to get the permanant links to work:

    replace these lines:
    //$url = get_permalink($post->ID);
    echo “<li><a href=\”$siteurl”.”index.php?p=”.$post->ID.”&more=1&c=1\” title=\”$text\” />$post_title</a>  <strong>($result->cntaccess)</strong></li><br/>”;

    with:
    $siteurl = get_permalink($post->ID);
    echo “<li><a href=\”$siteurl\” title=\”$text\” />$post_title</a>  <strong>($result->cntaccess)</strong></li><br/>”;

    [Reply] kilikina (5 comments.) — 03/17/2005 @ 2:50 pm
  16. I’m actually still running into the problem of the foreach not working on line 67 for pop posts. Anyone find a fix for that? I tried to debug it, but couldn’t hack it yet. I’ll keep playing with it, but thoughts on it?

    [Reply] Jonathan (12 comments.) — 03/17/2005 @ 3:04 pm
  17. Bah, I’ve run out of time. I’m leaving the country for a little over a week and won’t have time to make the update quite yet. If anyone feels like they want to make all the changes needed and e-mail it to me, I will update the file on hand for people to download.

    You can e-mail it to: yeahmmhmm@gmail.com — Hope everyone enjoys this plugin once it’s updated.

    [Reply] Jonathan (12 comments.) — 03/17/2005 @ 7:15 pm
  18. [...] Stats Depokerizer Acronym Replacer AutoLinker Blacklist Blogtimes Comment Quicktags Top 10 WP Grins WordPress M [...]

    揚之Blog » Wordpress加工記 — 03/18/2005 @ 11:32 am
  19. Are there any new updates on the directions to use this plugin?? Please let me know

    [Reply] Poonam (3 comments.) — 03/20/2005 @ 8:38 pm
  20. [...] ordpress: How to Install Post View Count/Top 10 Plugin

    I just installed this Top 10 Posts/Views Plugin by Laughing Lizard. It did take a little poking ar [...]

    PHP-Princess.net » Blog Archive » Wordpress: How to Install Post View Count/Top 10 Plugin — 03/25/2005 @ 12:15 am
  21. [...] er Acronym Replacer AutoLinker Blacklist Blogtimes Comment Quicktags Top 10 WP Grins Wordpress Mobile Edition WYSI-Wordpress Alternative Recen [...]

    無名小Blog » Wordpress加工記 — 03/29/2005 @ 10:12 am
  22. [...] 0:51 pm WordPress plugin:Top 10 Posts/Views 今天裝上了WordPress的一個plugin:Top 10 Posts/Views,他利用多設置一個SQL的table來記錄文章被cli [...]

    玩物喪誌Blog » WordPress plugin:Top 10 Posts/Views — 04/3/2005 @ 10:57 am
  23. Okay, I’m going to make an update to this script this weekend with the corrected code. Finally tweak it so it works just fine now. Give me a couple days and it will be updated for everyone to use :)

    [Reply] Jonathan (12 comments.) — 04/7/2005 @ 1:49 pm
  24. Wordpress Top10/View Count Plugin

    I released a ported version of Top10/View Count plugin about a month ago. I ported it over from the txt file that Laughing Lizzard had into a plugin so that it was easier to use. It had some bugs in it, so I decided to create some more documentation …

    BleakGeek.com — 04/8/2005 @ 8:55 pm
  25. [...]
    为装这个插件用了一下午的时间,来源是 [...]

    苟世录 » Blog Archive » Top 10 Posts/Views — 04/9/2005 @ 5:35 am
  26. [...] dPress: Batch Categories Plugin WordPress: Top 10 Posts/Views Su Weblog Tools Collection è disponibile un plugin che mostra i 10 articoli pià [...]

    WordPress Italy » Archivio Blog » Plugin WordPress: Top 10 Posts/Views — 04/24/2005 @ 6:21 am
  27. very nice!

    [Reply] Kahsoon (1 comments.) — 04/25/2005 @ 4:10 am
  28. i will use this for our malaysia camera blog - http://www.fotozzoom.com.my/wp/index.php

    [Reply] Foto-ZZoom (1 comments.) — 04/25/2005 @ 4:11 am
  29. [...] reat ones are already there. A few which I’ve been sampling and delighting in are: Top 10: Basically allows you to count number of views for each post and displ [...]

    incorporated subversion » Archive » WordPress plugins ahoy — 04/26/2005 @ 12:45 am
  30. [...] itles, but not show the post titles (and links) by date. The second plugin I installed is Top 10 Posts/Views. When you come to a site like this one, or even a news si [...]

    Super Jellyfish » Cool Plugins - Clean Archives and Top Posts — 05/3/2005 @ 10:05 pm
  31. [...] ess, Wordpress Dev by Jonathan Friday April 8, 2005 I released a ported version of Top10/View Count plugin about a month ago. I ported it over from the txt fil [...]

    BleakGeek.com » Wordpress Top10/View Count Plugin — 05/12/2005 @ 11:40 pm
  32. Is it possible to modify this to only show the top 10 posts of a given category?

    [Reply] Steve — 05/13/2005 @ 10:50 am
  33. No, sorry, that has not been coded nor is in the plan to do so. That would a lot more coding and plugin would be very extensive instead of the short and sweet plugin it is right now. But you are more than welcome to try to modify it yourself to try to get it to work.

    [Reply] Jonathan (79 comments.) — 05/13/2005 @ 11:40 am
  34. is there a way to exclude an ip or a user from the top10 count?
    so that the database doesn’t get updated for a certain ip or user?

    [Reply] yuri (1 comments.) — 05/20/2005 @ 3:39 pm
  35. There is nothing in the plans right now for that, it’s an as-is product and doesn’t have much or any development plans. You can try to code it in yourself though, if you wish. I simply ported it over to a plugin from which Laughing Lizard made, you may want to contact him about it.

    [Reply] Jonathan (79 comments.) — 05/21/2005 @ 12:47 am
  36. Thanks, I used this on my site. It’s exactly what I as looking for.

    [Reply] Ray (5 comments.) — 05/31/2005 @ 4:01 pm
  37. I got around the problem of showing only a specific category by having a custom single.php for the category, and only having the plugin counter for that index. :)

    [Reply] Steve — 06/1/2005 @ 8:08 am
  38. I found a way to cut the queries down from 11 to 1, I e-mailed the author so he can update the code, and I posted a comment for it on my site: http://raybdbomb.com/05.31.200.....omment-964

    [Reply] Ray (5 comments.) — 06/2/2005 @ 12:15 pm
  39. Thank Jonathan to create this plug-in. It is useful! I am wondering where can I put a code and show up the total visited amount of my blog? Is it possible? thanks!

    [Reply] prattflora (1 comments.) — 06/6/2005 @ 3:20 am
  40. Do you mean the total visiter to your blog or the total visiter on a per post basis? Right now it works fine on a per post basis, that’s how I have my site setup. http://www.bleakgeek.com if you wish to take a look. Let me know how it goes : )

    [Reply] Jonathan (79 comments.) — 06/7/2005 @ 12:24 am
  41. [...] log tweaks here and there whole week… Page Views - I was finally able to make the Top10 to work with the rest of the other plugins. Entries now have pageview c [...]

    Ambot ah! » Tweaks ’round and about. — 06/24/2005 @ 4:53 am
  42. One major problem I see with this plugin is that one use can keep refreshing on the post and have the view count just keep going up.

    I make a workaround for this; if a user has seen that post, it won’t increment it again. I.e. it has turned into “view per post” to “view per post per user” sort of thing.

    See my post for info on how to edit it, or if the author would like to add it to his plugin.

    [Reply] Ray (5 comments.) — 06/25/2005 @ 2:06 pm
  43. Jonathan, how do I create a list of the most viewed posts?

    [Reply] Tim Yang (2 comments.) — 08/3/2005 @ 11:56 pm
  44. Follow the instructions that come with the plugin and it tells you how.

    [Reply] Jonathan (79 comments.) — 08/4/2005 @ 12:14 am
  45. Top Ten Posts and Views Problem

    Recently, the plugin Top Ten Posts/Views installed on my Wordpress system is running good. My recent version of the Wordpress is version 2.0.1.
    However, after upgrading my system to Wordpress version 2.0.2, I noticed that these plugin stops recording t…

    SELaplana — 05/20/2006 @ 11:55 pm
  46. [...] Top viewed posts plugin Another powerful method you can do is to install the top views plugin. This plugin can display the most popular posts in your blog, thus attracting more readers and improve your pageviews. I think you can change the default number to display, I usually will display the top 15 most viewed posts. [...]

    Wideon.net - The Best Free Link Submission Directory on the Net » Blog Archive » Full Steps To SEO Wordpress Blog — 09/9/2006 @ 4:38 pm
  47. [...] Weblog Tools Collection - Top 10 Posts and Views WordPress Plugin on your Blog [...]

    Creating Effective, Attention-Getting Headlines and Titles « Lorelle on WordPress — 09/20/2006 @ 8:58 am
  48. test

    [Reply] Mark (118 comments.) — 09/20/2006 @ 10:02 am
  49. Another test

    [Reply] Mark (118 comments.) — 09/20/2006 @ 10:17 am
  50. the most important plugin for wordpress
    thanks

    [Reply] selim (1 comments.) — 09/20/2006 @ 2:57 pm
  51. Hi,

    im using this plugin and I was wondering,It counts the views to every single page on my site and displays them in the top list,including the contact us section about ect… is there any way to filter the pages you want it to count?

    [Reply] Matty — 09/30/2006 @ 10:02 pm
  52. Anyays to filter the pages you want counted?

    [Reply] Matty — 09/30/2006 @ 10:03 pm
  53. [...] Install these SEO-friendly WP plugins — Optimal Title, Related Posts, Simple Tags, Ultimate Tag Warrior, Permalinks Redirect, Google Sitemaps, Top10, Get Recent Comments, Add Meta Tags. [...]

    A Guide to an SE Optimized Wordpress Setup » @ Ambot ah! [ technology news and reviews ] — 10/7/2006 @ 8:19 am
  54. [...] Top 10 posts - Looks like a promising little tool, for both content management and news portals. [...]

    Brian’s Business Blog » Essential plugins for Wordpress — 10/9/2006 @ 11:03 am
  55. [...] Cria um google sitemap do seu site. O site map é um arquivo xml que diz quais páginas fazem parte do seu site. Assim, facilita a vida do Google a rastrear seu site. Muito bom. (SEO optimization) Top 10 [...]

    Gus’s SOS » Blog Archive » Plugins WordPress - Eu uso — 11/3/2006 @ 8:48 pm
  56. [...] AdSense-Deluxe -an easy way to organize google ads. CG-SameCat -generates a list of pages in the same category. Category Order -customize the order and hierarchy of categories. WP-EMail -email posts to a friend. Feedburner Feed Replacement -directs RSS feeds to feedburner. Google Sitemaps -creates a Google-friendly sitemap. Bookmark Me -those multi-colored links you see everywhere. Tags in the Head -a way customize meta tags Top 10 Posts -counts post views and lists the top 10. Underscore Permalinks -uses _ instead of - in permalinks. Ultimate Tag Warrior -organizes tags for each post. Random Quotes -those random phrases just below the header. Contact Form -a simple contact form. [...]

    How to Blog :: The Manual — 11/4/2006 @ 1:56 am
  57. [...] Hoje resolvi colocar a mão na massa e migrei os dados gerados pelo plugin Top 10 e passei a usar o plugin WP-PostViews. Eu estava pensando em fazer esta mudança já tem algum tempo, mas ficava me torturando que os dados não poderiam ser reaproveitados. Hoje, com toda a calma que um feriado enforcado pode me dar, coloquei a mufa para funcionar e migrei. Foi supersimples. Para você não muda nada, mas para mim, melhora a estatística e controle sobre atualizações de versão. [...]

    bernabauer.com - Troca de plugin — 11/4/2006 @ 9:49 am
  58. [...] Top 10 Posts - gives you the top 10 posts by views, very hackable see my top 100 posts for an example.  [...]

    A WHUer’s Blog » Blog Archive » Digest:Essential Wordpress Plugins — 11/23/2006 @ 2:36 am
  59. It adds two points per visit in my blog! how can it be possible
    I have checked and i only have add_count once

    [Reply] xavy (1 comments.) — 12/4/2006 @ 4:08 pm
  60. [...] AdSense-Deluxe -an easy way to organize google ads. CG-SameCat -generates a list of pages in the same category. Category Order -customize the order and hierarchy of categories. WP-EMail -email posts to a friend. Feedburner Feed Replacement -directs RSS feeds to feedburner. Google Sitemaps -creates a Google-friendly sitemap. Bookmark Me -those multi-colored links you see everywhere. Tags in the Head -a way customize meta tags Top 10 Posts -counts post views and lists the top 10. Underscore Permalinks -uses _ instead of - in permalinks. Ultimate Tag Warrior -organizes tags for each post. Random Quotes -those random phrases just below the header. Contact Form -a simple contact form. Get Recent Comments -displays recent comments in the sidebar Kramer -displays recent inbound links in the sidebar [...]

    How to Blog :: The Manual — 01/12/2007 @ 3:41 am
  61. i cant find

    in my index.. im using wordpress 2.1

    [Reply] raaja — 02/24/2007 @ 4:38 pm
  62. For wordpress 2.1 onwards, add these codes

    no permalinks:
    0) { add_count($p);}?>

    using permalinks:
    0) { add_count($id);} ?>

    in single.php of your themes folder, under

    Hope this helps.

    [Reply] J — 02/28/2007 @ 9:02 am
  63. Is there a way to set it to a different number than 10? say, 15 or 20?
    Thanks.

    [Reply] Babak (1 comments.) — 03/11/2007 @ 1:57 pm
  64. [...] with Wordpress 2.0 and 2.1. Disclaimer: This is a standalone plugin. If you have been using the Top 10 plugin, please be advised that using the Daily Top 10 Posts plugin means your pageviews will, once again, [...]

    Alleba Blog » Wordpress Plugin: Daily Top 10 Posts — 03/27/2007 @ 3:27 pm
  65. [...] to a tip from podz, I installed Top 10 Posts/Views plugin. This gave me the functionality of showing view count for each post, and showing the 10 most [...]

    Teh Blarg » Top 10 Posts/Views — 03/31/2007 @ 3:33 am
  66. how to add table using phpadmin?

    [Reply] php noob — 05/12/2007 @ 2:00 pm
  67. [...] Visit [...]

    WP Plugins DB » Blog Archive » Top10/View Count — 05/20/2007 @ 4:04 am
  68. [...] Top 10 Post/Views it shows how many times posts have been viewed. (Sorted by number of viewed) [...]

    Blog & WordPress » Statistics plugins for WordPress - Counting — 06/21/2007 @ 12:44 pm
  69. [...] there’s the Top Ten Plugin, from Californian Johnathan, who’s got tons of other Wordpress stuff as [...]

    Lefthandedlayup » Blog Archive » Now Blogging - The U.P. Portia Sorority! — 06/24/2007 @ 9:01 pm
  70. [...] Visit [...]

    WP Plugins DB » Plugin Details » Top10 — 07/17/2007 @ 7:50 am
  71. [...] Top10 Top 10 Posts/Views [...]

    » How To Build Your Own Multimedia Site With WordPress — 10/8/2007 @ 4:38 pm
  72. [...] Top 10 Posts - gives you the top 10 posts by views, very hackable see my top 100 posts for an example. [...]

    tool set for wordpress : fredklumpp.com — 11/5/2007 @ 6:43 pm
  73. [...] with Wordpress 2.0-2.2. Disclaimer: This is a standalone plugin. If you have been using the Top 10 plugin, please be advised that using the Daily Top 10 Posts plugin means your pageviews will, once again, [...]

    Freemaxsite.com » Daily Top 10 Posts — 11/6/2007 @ 3:04 pm
  74. [...] ???????? ?? ??? ??? ??? ??? ??? ???? ???? ?? ??? ?? ??? ??? ??? ??? ?? ???? ?? ???? ?? ?????? ?? ?? ?? ?? ????? ???? ???? ??? [...]

    urdu bloggin plugin tidbits | ?????? — 12/31/2007 @ 5:23 pm
  75. [...] Top 10 Posts – Another one of the WordPress navigation plugins, this plugin will help to reinforce linking to your best pages. [...]

    WordPress SEO plugins: choose the best free WordPress plugins for your site. — 01/3/2008 @ 3:14 pm
  76. [...] viewed posts pluginAnother powerful method you can do is to install the top views plugin. This plugin can display the most popular posts in your blog, thus attracting more readers and [...]

    Full Steps To SEO Wordpress Blog » Web Marketing | Search Engine Optimization | Direct Marketing- thewebmarketingblog.com — 01/15/2008 @ 3:54 am
  77. [...] Top 10 Posts - gives you the top 10 posts by views, very hackable see my top 100 posts for an example. [...]

    Incredible WordPress Plugins Get Optimized | Alligatorcat Adobe News — 03/22/2008 @ 6:53 pm
S2