Data Mining is my profession. So I wouldn’t run a weblog without a decent site traffic tracking and analysis tool. I’m using Mint by Shaun Inman, and I dare to say I’m a real fan.
Since Mint is tracking only human interactions and thus the real clicks to particular blog posts it is the perfect source for an unbiased favourites list as you can see in my sidebar.
Several developers already had the same idea and published code for this very purpose, among them Philip Lindsay, Cody Williams and Yaakov Ellis. Yaakov even mastered the challenge of writing an efficient WordPress plugin.
I’ve used Yaakovs plugin (with some minor modifications) for quite a while. While checking my other plugins for compatibility with the upcoming WordPress 2.3 I decided to refactor this plugin in order to make it configuration-free and easy to install and let it cache its query results using WordPress‘ very own caching mechanism.
I’m releasing this version as MintPopularPostsWP. A working Mint installation is required. If you want to benefit from caching you have to enable the WordPress cache (see the README.txt) for further instructions.
Installation is simple. Just upload the plugin and activate it. You will find a new options page „Mint Posts“ in your WordPress Admin Panel. Change the options as you need them. Users with a Mint DB residing in another database than WordPress have to set their database access credentials and connection information. Don’t forget to save the options before leaving the options pane.
You may then place a call to MintPopularPostsWP in your sidebar template code like this:
<h2>30 Most Popluar Posts</h2>
<ul>
<?php mpp_popular_posts( 30 ); ?>
</ul>
You may also be interested in showing off your Mint Watchlist including the hits and number of external referrers. It works like this:
<h2>30 Mint Watchlist</h2>
<ul>
<?php mpp_watched_posts( 30 ); ?>
</ul>
As a bonus you might want to display the visits/visitor counts. For this purpose you can use the parameterless function mpp_mint_stats():
<h2>Mint Visit Statistics</h2>
<ul>
<?php mpp_mint_stats(); ?>
</ul>
The output of the code above may look like »» this. The plugin has been tested with WordPress 2.2 and 2.3.
mpp_popular_posts
Parameter | Default | Description |
---|---|---|
$num_posts | 10 | The number of posts to display |
$prev_days | 0 | How many days would you like the list to run for? For all posts, enter 0 (default). Any other number (X) will retrieve the top posts in the last X days |
$text_to_remove | “ | The text to remove from each post title that is displayed. For example, if every title begins with „« Turmsegler“ it would be redundant to enter this as part of the link text for every post listed. |
$ignore_list | “ | comma-separated list of URLs (including http://) that should not be counted in the popular posts list (wildcard = * or %) |
$ignore_extensions | “ | comma-separated list of file extensions to ignore (wildcard = * or %) |
$include_count | true | Should the count for each post be displayed? |
$include_www | false | Should a „www“ be appended to the beginning of every url (changing https://turmsegler.net into http://www.turmsegler.net)? |
$pre | <li> | the html that should be included before every post listing |
$post | </li> | the html that should be included after every post listing |
mpp_watched_posts
Parameter | Default | Description |
---|---|---|
$num_posts | 10 | The number of posts to display |
$text_to_remove | “ | The text to remove from each post title that is displayed. For example, if every title begins with „« Turmsegler“ it would be redundant to enter this as part of the link text for every post listed. |
$include_count | true | Should the count for each post be displayed? |
$include_www | false | Should a „www“ be appended to the beginning of every url (changing https://turmsegler.net into http://www.turmsegler.net)? |
$pre | <li> | the html that should be included before every post listing |
$post | </li> | the html that should be included after every post listing |
mpp_most_commented
Parameter | Default | Description |
---|---|---|
$num_posts | 10 | The number of posts to display |
$pre | <li> | the html that should be included before every post listing |
$post | </li> | the html that should be included after every post listing |
Download: » MintPopularPostsWP-111.zip (Version 1.1.1 • 05.04.2008)
Am 5. September 2007 um 07:40 Uhr
Nice work with the plugin. I like the way that you are handling the caching to use the system built-in to wordpress. In my next iteration, I will try to change the way that my plugin handles caching to use this method for caching. – Yaakov
Am 5. September 2007 um 08:01 Uhr
Hi Yaakov, nice to see you came along to check it out.
The caching is not the only changed feature. I only show blog posts and display the real headline of the posts instead of the page title which can be quite long and unfit for a list. (I’ll try to find a way to make that configuarble). The access count is always shown via fly-over (title attribute of the links).
Since I need the WordPress DB to find out whether a resource is a blog post and what the original headline was I can however not use a Mint DB in another MySQL database. This is sad.
Last but not least: The plugin should get an options panel in order to avoid source code editing for setting the options. I’ll let you know when I make progress with these issues. Maybe we can integrate the feature set into just one plugin…
Am 6. September 2007 um 15:50 Uhr
Update 06.09.2007:
I did finally merge the current feature set of Yaakovs Plugin, added an options panel for the WordPress Admin GUI and added the new method mpp_watched_posts for display of the Mint Default Peppers Watchlist (inlcuding hit and external referrer counts). I’ve also added support for Mint DBs residing in another DB instance than WordPress.
Since the changes are now substantial compared to Yaakovs plugin I’ve decided to make it a real release. If you find bugs or have suggestions regarding future enhancements, feel free to leave a comment here or send a mail using the contact form.
Am 7. September 2007 um 09:49 Uhr
Update 07.09.2007
The Mint Watchlist did show hits from external referrers only. This differs from the behaviour of the Default Pepper in Mint and has been changed. The Watchlist is now reporting exactly the same figures as the Default Pepper in Mint.
I have added a dynamic sample output of both methods to the options panel. This way you can immediately validate your settings and see the result without first integrating it into your WordPress theme.
Am 8. September 2007 um 10:28 Uhr
Vielen Dank! Endlich funktioniert auch das Entfernen meines Blogtitels und durch das Caching lädt die Seite noch mal schneller.
Daniel
Am 12. September 2007 um 09:33 Uhr
Great plugin!
I choose to use this plugin along with Yaakovs plugin. With Yaakovs plugin I can display the popular post within the last 7 days (for example) I didn’t find this on yours.
Am 12. September 2007 um 09:40 Uhr
@Bakkell: The syntax is exactly the same as with Yaakovs plugin. For your purpose just call:
mpp_popular_posts( 30, 7 );
Means: Display the top 30 posts from the last 7 days.
Am 12. September 2007 um 09:42 Uhr
@benjamin Thanks!! Now it’s perfect ;-)
Update: Hmm, no it’s not. It puts out the same data. check
my frontpageor » this one.Am 12. September 2007 um 14:17 Uhr
Update 12.09.2007
Method mpp_popular_posts parameter $prev_days did not have an effect. This has been fixed.
Synopsis for methods added to
README.txt
andMintPopularPostsWP.php
as well as this post.Am 12. September 2007 um 14:18 Uhr
@Bakkel: You where right. It’s been a bug. You’ll find it fixed in Version 1.01.
Am 12. September 2007 um 15:15 Uhr
@benjamin Yep, all works fine now! thx!!
Am 29. September 2007 um 09:44 Uhr
[…] Mint Popular Posts utilizes Mint, one of the best tracking packages for complete analysis of your website traffic. Find out which pages your visitors are reading, which links they’re clicking, which ad’s they’re clicking, and more. […]
Am 1. Oktober 2007 um 18:08 Uhr
[…] Mint Popular Posts utilizes Mint, one of the best tracking packages for complete analysis of your website traffic. Find out which pages your visitors are reading, which links they’re clicking, which ad’s they’re clicking, and more. […]
Am 5. Oktober 2007 um 01:56 Uhr
Beautiful widget
Few problems:
Can’t get it working on the blog though. The top posts show up properly in WP options but not live.
Need text removed from the end of each post title; your code seems to only remove from the beginning. Any way to do that?
Want the www added before each link do I just include that in the code snippet?
Thanks alot!
Am 6. Oktober 2007 um 21:23 Uhr
You have to include the PHP code in your template e. g. for the sidebar. The text you wish to remove would be removed at any location in the title. Let’s assume you use the default WordPress behaviour where the blog name is appended to the post title and you want to add www to every URL:
<ul>
<?php mpp_popular_posts( 10, 0, '» Your Blog Title', '', '', false, true ); ?>
</ul>
The special characters » and « must always be entered as they appear in the source (HTML encoded!).
Please not that WordPress 2.3 does not use your sidebar template in case you use the new widget mechanism.
Am 29. November 2007 um 23:21 Uhr
Update 29.11.2007:
As a bonus you can now also display the visits/visitor counts:
<h2>Mint Visit Statistics</h2>
<ul>
<?php mpp_mint_stats(); ?>
</ul>
Am 31. Dezember 2007 um 19:51 Uhr
Is there a way to get this plugin to show up in the widget admin screen so i can drag it into my tabbed sidebar? Otherwise i can’t get it into the tabbed sidebar.
Am 31. Dezember 2007 um 21:04 Uhr
I will widgetize the plugin in the next version. Please check back in about 10 days. I still have to make the widget configurable and do some testing on the new code.
Am 2. Januar 2008 um 10:29 Uhr
I have an odd problem. If I include the code as a widget, widgets that use wp_list_pages that follow it will return no pages at all (I use the exclude pages parameters). If I put the new widget after them, no problem. The problem is (and I use problem too much I know) that I don’t want it at the end of all the widgets in the right sidebar.
I looked for a conflict but I couldn’t find one.
Am 29. Januar 2008 um 17:28 Uhr
[…] actually one of those developers. My WordPress plugin MintPopularPostsWP needs access to the Mint database. Mints database tables can safely reside within the WordPress […]
Am 29. Januar 2008 um 22:58 Uhr
Update 29.01.2008:
In version 1.1 I was able to fix once for all the external database issue.
The major new feature is nevertheless that the plugin does now provide widgets for the Mint Popular Posts List, Mint Watchlist, Mint Visitor Statistics.
Have fun.
Am 10. März 2008 um 18:04 Uhr
Thanks for the great plugin! I works so far (the only problem I have is that the title of my blog doesn’t always get removed from each of the top posts).
I was wondering if this would be possible: I’m trying to make the mpp_watched_posts() be listed based on the number of Referrers instead of Hits. Is that possible?
Something else I’m curious about is whether it would be possible to consider the number of comments on a post when calculating how popular the posts is (this would duplicate some of the functionality of Alex King’s Popularity Contest plugin).
Thanks again!
Am 10. März 2008 um 20:48 Uhr
Please check the real code of your pages. The title of WordPress blog posts usually contains » or « You have to write this code in the filter input box not the decoded character.
Write » for » and write « for «. That works.
It would be. But this is an entirely different approach. Mint tracks clicks and this plugin is using Mint data. You should use one of the other mere WordPress plugins for the purpose you’re describing.
On the other hand… It would be so easy to implement… So this feature might show up in an upcoming version. Bli neder! (Without any oath!)
Am 10. März 2008 um 21:10 Uhr
Curiously, this works for almost all the posts, but not some. So i’ll have a list of the top 10 posts and one or two of them will still have the title of the blog in it. If I change the prev_days, it will show a different set of posts with the blog title still in there. Weird. I may be because I have both the » and brackets ) and ( in my blog title.
That would be great! I’d be willing to send you a donation via paypal if that would provide some incentive. Send an email to my address if this suits you.
Thanks again for the great plugin.
Am 10. März 2008 um 22:13 Uhr
My incentive would be to make a lucky users day. Another tip: Check the „Optimal Title“ plugin. And check within the page code whether some other characters in your titles are encoded as well.
Am 10. März 2008 um 22:24 Uhr
haha fair enough :)
Thanks for the info on Optimal Title.. good to see that WP2.5 will have this integrated into core.
Am 10. März 2008 um 22:31 Uhr
That’s great news. Thanx for the info. BTW: I’m just implementing the new feature. Check back in a while. I will release it after some testing.
Am 10. März 2008 um 23:14 Uhr
Wow, that’s awesome!
I look forward to trying it out. Thanks again.
Am 12. März 2008 um 09:39 Uhr
Hi Ben,
Sorry to bother you again about your great plugin.
I have a question about the $prev_days parameter. If i use ( 10, 30 ) to show the last 10 posts in the last 30 days, it shows the top 10 posts out of all the posts on the site and then takes the number of hits in the last 30 days.
Is it possible to show the top 10 posts out of ONLY the posts that have been submitted in the last 30 days? This would help keep the newer posts in circulation longer.
Thanks!
Am 12. März 2008 um 10:23 Uhr
I think about it. Should be possible with an extra parameter for the function.
Am 20. März 2008 um 05:28 Uhr
Hi Benjamin,
Out of all the „most popular post“ plugins I’ve seen so far, this is the only one I’m able to make some progress so far. Not much luck on the others, but it’s probably just me. :(
Anyway, since I’m using widgets, I put „Mint Popular Posts“ at the left sidebar of my blog. I renamed it to „Popular Posts“ and set it to show the top 5, but…it’s not showing anything.
I looked at the Mint Popular Posts Options and, sadly, am not able to make much head or tails with it. I’m thinking of maybe manually setting it (for now) to show the top 5 based on results from another plugin I’m using called Click Tracking for now, but not necessarily, say, loading the mysql thing for both of them.
If I’m not really clear on that last paragraph above, feel free to say so. Even I myself am struggling to figure out the right words to explain my desire. :D
Am 20. März 2008 um 07:52 Uhr
Hi David, please read the article above and the description of the plugin. It requires the data collected by the Mint web tracking system. If there is no Mint database or no data in the Mint database it cannot show nothing.
Am 20. März 2008 um 09:16 Uhr
I forgot to mention I read the documentation prior to this. But I guess I wasn’t really sure until you finally confirmed it.
Oh well, I’ll give that a shot. Thanks!
Am 6. April 2008 um 12:24 Uhr
Update 05.04.2008:
As a bonus you can now also display a favourite list base on the comment count:
<h2>Most Commented Posts</h2>
<ul>
<?php mpp_most_commented(); ?>
</ul>
This function (as well a the corresponding widget) can be used without a Mint installation. It uses the WordPress tables only.
Am 4. Mai 2008 um 09:44 Uhr
Hi Benjamin,
thanks a lot for your plugin. It works great so far except from the empty Tags that are generated when posts are filtered out. Is there a way to get around this? The filtered posts whouldn’t affect the number of posts shown? When using 10, 30 (10 posts from 30 days) it just outputs 5 post links plus 5 empty fields.
Am 4. Mai 2008 um 09:49 Uhr
Hi Frank, I don’t undestand the problem. Please send a mail. I understand German :-)
Am 12. Juli 2009 um 18:32 Uhr
Hi followers, I just want to give an update regarding this plugin and the new WordPress Version 2.8 and up. The guys at wordpress.com point out that MintPopularPosts is not 100% well behaving with the new version since it uses a separate database connection when it should use the default WordPress database connection object. Well, this is – first – optional and – second – a feature for Mint users having their Mint database in a different database than their WordPress data. To provide this optional feature I obviously cannot rely on the services of WordPress and have to use a separate database connection.
This said I can tell you that MintPopularPosts is compatible with WordPress 2.8 and 2.8.1.