After much goading from a few well wishers, I finally had the chance to clean up and build a plugin out of the Top 10 Posts and Views per post hack for WordPress. This should work and has been tested on WordPress 1.5 and WordPress 2.0 beta. Please post bugs, suggestions etc.
Installation should be very simple. Upload the plugin, enable and then add the single line function(s) to your template where you want the display. Example at my GreenCar blog.
Top 10 and most viewed Download [EDIT] Plugin Updated for 1.5 support. Please redownload if you were having problems.
I’m getting this error: Warning: Invalid argument supplied for foreach() in /home/ktrame/public_html/wp/wp-content/plugins/top10.php on line 70
I’ve clicked on a bunch of my entries and it’s still not working.
why not use the postmeta table instead of creating a new one ?
To keep it backwards compatible with older versions and keep it from muddling with the WordPress datastructures.
Yeah. That’s what i need. Thanks!
Sorry. But it doesn’t work. The table doesn’t become updated. I clicked on some entries.
I’m getting the same error like Katie.
Sam and Katie, does the table get created? Do you get any errors on the single post view screen?
I’m not exactly clear on where I should be looking for this table….
Yes the table was created and i get errors in the single post view.
There is no data in the table mostAccessed.
Just checked phpMyAdmin and yes, the table is there but like Sam, there is no data. Errors in the single view as well.
If this helps, I’m getting a warning sign saying “PRIMARY and INDEX keys should not both be set for column `postnumber`”
Hi Mark – I’m still getting the hang of wordpress internals, but it looks like you’re trying to add an action for “loop_start”, but it’s not obvious to me when that action is actually done. I can’t find “loop_start” in any of the WP code. Is it possible that that’s from WP2.0? I’m running 1.5.2
Thanks!
Kaufman, you are right. It looks like loop_start was only added in 2.0+ (which means my 1.5 test blog is fubar) I have made some changes to the plugin. Please check to see if this one works.
Works great now – many thanks!
It works. Thanks. But i added an
echo '';
after the output.It’s working now, thanks! Now, if only you could set it up to not count my own hits. 🙂
Can someone please fully test these hacks that they are compatible, or better yet, compile a .php to apply them and if you have to just query the database.
Everytime i go to a plug ins Blog i find nothing in comments but tons of errors. This is frustrating and not encouraging for advancing WP. Thanks
Oh, also a suggestion, if you’re taking them… not having pages show up in the post count. I have my archives by date all on a separate page, and that page shows up as a popular post now.
I agree with Katie. It would be great if the plugin didn’t show pages, only posts!
Thanks for a fun and easy plug-in. I’m not much at PHP, but should there be a closing ul tag in the function show_pop_posts()?
If you have ever written code, you should know that bugs are a part of life for us programmers. It is IMPOSSIBLE to “fully test” plugins since every blog is different, every bit of code is different and with the preponderance of a variety of different cooks in the broth, there are numerous versions of WordPress being used. Plugins are especially more vulnerable to naked errors since plugin authors do not have a ready set of beta testers who could point out possible errors. They just use their own test blogs to make sure that eveyrthing they can fix, is fixed before the initial release.
I do not think that plugin bug reports are discouraging for WordPress, nor are they in any way damaging to the “advancing” of WordPress. I sincerely hope that you (and others like you) are not turned off by the fact that people report problems (which are then hopefully fixed) on new code.
Well said, Mark – as a programmer myself, I can only back you up on the fact that testing every possible permutation of systems is pretty much impossible.
Folks, if you are not interested in helping to isolate and test those permutations, then please do NOT apply plugins or other code that is in any state of development. WP works great “out of the box” – if you want anything more than that, then you’ll have to accept the responsibility of living with “in-development” code.
I’m getting some wacky things going on with my top 10 list. Some entries keep showing up on the list twice, even though it’s the same exact entry (same post ID and everything). Then I have one line that just says (2) with no title.
I got the same problem as Katie. A post keep showing up randomly and in my case it is on number 1 of the list. The number of visits don’t change though, it’s just the post title.
I kind of figure out the pattern of the error in my blog. The number 1 post showing up on my top 10 list is always the most bottom post on the front page. So if the post on the far bottom of my front page changed, it will become the number 1 on the list. Hm.
Yes. I have the same error.
While i am viewing a post, the post is the most viewed post in the list.
Update plugin, please check. I have to run but will explain when I have a minute.
Ok, now it works. But the
tag is still missing…
Is there an easy way to reset all the counts? I deleted some test posts but they still show up in Top 10 without subject and just the hit count showing? Still love this plug in!
Hello, I got a probplem with the url the plugin creates. Normaly the top 10 list would write the list and then make you click the article to read it. Am I right? But on my page the url on each article in the top10 list is the url to the page I have the top10 list on. Check http://tilkoblet.net/blogg/?page_id=29 to see what I mean.
How do I fix this?
Sorry for asking a stupid question but what exactly does the plugin count? I’m asking this because I’m currently comparing several statistical tools, and while the differences between the others (Measure Map, Mint, Google Analytics) are only minor, those of Top10 are enormous. E.g., according to the plugin, my most accessed post (with twice the amount of the post ranked at #2) is a rather obscure one that hardly gets noticed by the other tools. And most of the posts in my Top 10 still continue to grow exponentially (compared to the other posts) even though this includes some more or less “outdated” posts which according to the other tools aren’t visited at all anymore.
How can this be? Does the access count also include search engine crawls and suchlike?
How about a “top 10 emailed”?
Can you add a function to count the number of post emailed for those of us using WP Email?
Thanks a lot fot the plugin! I have a couple of questions though:
1. Seams like counter functions does count bots, so the numbers of views grows very fast almost every minute. Can that be fixed?
2. Is there a way to avoid rating pages? I see that pages I created in wordpress also in the Top 10 Posts.
I see a number of comments mentioning that the plugin rates pages as well as post. I don’t know how to avoid the page rating but maybe there is a way to avoid listing certain pages.
Wordpress has the abillity to “exclude” pages from lists. I can’t get it to work though.
If anybody finds a solution please post it.
As far as the rating pages bit goes, it should be possible to exclude the pages with the is_page() function. I haven’t looked at the code yet, but it returns a boolean so you should be able to us an if then bit to filter out pages.
Also, I just downloaded this plugin about 4 days ago and am getting the error where one post appears multiple times on the list. Is there a fix for that yet? Any ideas on what causes it, so I can tinker around with the plugin code?
Thanks,
Ok, I believe I figured out the duplicate entries bit.
Why it creates them I don’t know cause it shouldn’t, but if you want to eliminate them, the hack is to make the postID in the mostaccessed table a unique field. That way there can only be one instance of each id. You will have to delete any duplicates before you do this, so it might throw off your numbers for a while, but it will eliminate the duplicate issue from there on.
First, thanks for the time spent on developing a plugin for the comunity.
Second, the question 😉 : is it possible…
(i) to show more than 10 posts. Is it ok to change the number, only ?
(ii) to show the complete lists of all posts with the number of times they have been viewed. This could be displayed on a page that only the author can see (a list of maybe 500 posts would be unappropriate to be seen by everybody). Or may be it is possible to have two functions : one to show the top10 and another one to show the top-wahteveryouwant ?
I’ve just modified top10.php quickly to support sidebar widgets, for those so-inclined: http://www.tbble.net/wp/top10.phps.
Ok. Now I understand why you do not answer. Probably because it is quite explained in the file…
The blog linked above does not appear to display the Top 10 Posts plugin as the post says it does. Is it possible to see it in action on someone’s blog??
The blog linked above does not appear to display the Top 10 Posts plugin as the post says it does. Is it possible to see it in action on someone’s blog??
The blog linked above does not appear to display the Top 10 Posts plugin as the post says it does. Is it possible to see it in action on someone’s blog??
Can you help me please…I couldnt’ find
in my index.php
What I have is this:
Nice plugin. Great work.
How do I fix the views. On my index page it only shows the views at the very bottom of the page.
Can someone help me out please.
In the mostaccessed table in the db the data gets truncated, my last line is:
`mostAccessed` (`accessedid`, `postnumber`, `cntaccess`) VALUES (211, 254, 1);
that is without the “INSERT INTO” part. I’ve tried emptying the table and starting again but same thing happens.
I got the same problem as Katie. A post keep showing up randomly and in my case it is on number 1 of the list. The number of visits don’t change though, it’s just the post title.
Cheers – I’m looking to run a Poll on the top #10 or #20 plugins
I made ja(broken Japaneze) localized version:
http://takumiya.s13.coreserver.jp/error500/?p=13
I just put together a list of my own. Take a look! http://www.wuhangotyouall.com/.....plug-ins/I just put together a list of my own. Take a look! http://www.wuhangotyouall.com/.....-plug-ins/
thank you for this tip. This tool is still today a big help for us bloggers to analyse our best top 10 Posts.