WP-Plugin MintPopularPostsWP

4. September 2007

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

ParameterDefaultDescription
$num_posts10The number of posts to display
$prev_days0How 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_removeThe 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_listcomma-separated list of URLs (including http://) that should not be counted in the popular posts list (wildcard = * or %)
$ignore_extensionscomma-separated list of file extensions to ignore (wildcard = * or %)
$include_counttrueShould the count for each post be displayed?
$include_wwwfalseShould 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

ParameterDefaultDescription
$num_posts10The number of posts to display
$text_to_removeThe 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_counttrueShould the count for each post be displayed?
$include_wwwfalseShould 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

ParameterDefaultDescription
$num_posts10The 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)

37 Reaktionen zu “WP-Plugin MintPopularPostsWP”

  1. Yaakov Ellis

    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

  2. Benjamin Stein

    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…

  3. Benjamin Stein

    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.

  4. Benjamin Stein

    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.

  5. Daniel

    Vielen Dank! Endlich funktioniert auch das Entfernen meines Blogtitels und durch das Caching lädt die Seite noch mal schneller.

    Daniel

  6. Bakkel

    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.

  7. Benjamin Stein

    @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.

  8. Bakkel

    @benjamin Thanks!! Now it’s perfect ;-)

    Update: Hmm, no it’s not. It puts out the same data. check my frontpage or » this one.

  9. Benjamin Stein

    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 and MintPopularPostsWP.php as well as this post.

  10. Benjamin Stein

    @Bakkel: You where right. It’s been a bug. You’ll find it fixed in Version 1.01.

  11. Bakkel

    @benjamin Yep, all works fine now! thx!!

  12. Essential Wordpress 2.3 Plugins , Blog To Do - Free Blog Service

    […] 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. […]

  13. My Online Marketing Experiences » Blog Archive » Essential Wordpress 2.3 Plugins

    […] 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. […]

  14. Paul

    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!

  15. Benjamin Stein

    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, '&raquo; 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.

  16. Benjamin Stein

    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>

  17. Charlie

    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.

  18. Benjamin Stein

    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.

  19. RT Cunningham

    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.

  20. Separate DB connection for WordPress plugins « Turmsegler

    […] actually one of those developers. My WordPress plugin MintPopularPostsWP needs access to the Mint database. Mints database tables can safely reside within the WordPress […]

  21. Benjamin Stein

    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.

  22. ec

    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!

  23. Benjamin Stein

    the only problem I have is that the title of my blog doesn’t always get removed from each of the top posts

    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 &raquo; for » and write &laquo; for «. That works.

    whether it would be possible to consider the number of comments on a post when calculating how popular the posts is

    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!)

  24. ec

    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.

    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.

    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!)

    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.

  25. Benjamin Stein

    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.

  26. ec

    haha fair enough :)

    Thanks for the info on Optimal Title.. good to see that WP2.5 will have this integrated into core.

  27. Benjamin Stein

    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.

  28. ec

    Wow, that’s awesome!
    I look forward to trying it out. Thanks again.

  29. ec

    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!

  30. Benjamin Stein

    I think about it. Should be possible with an extra parameter for the function.

  31. David

    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

  32. Benjamin Stein

    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.

  33. David

    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!

  34. Benjamin Stein

    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.

  35. Frank

    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.

  36. Benjamin Stein

    Hi Frank, I don’t undestand the problem. Please send a mail. I understand German :-)

  37. Benjamin Stein

    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.

Einen Kommentar schreiben

XHTML: Folgende Tags sind verwendbar: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>