ArticlesForumDownload AboutContact

boakes.org

nice of you to drop by. tea?

Tags: Releases, WordPress

MostWanted - a Popular Posts Plugin for WordPress

November 24th, 2004, by Rich.


Warning: apache_lookup_uri() [function.apache-lookup-uri]: Unable to include '/pics/2005/mostwanted/mostwanted' - error finding URI in /home/www/boakes.org/htdocs/mods/plugins/boakes-depicticon.php on line 65
MostWanted - a Popular Posts Plugin for WordPress

This WordPress Plugin which lists the most popular posts in a blog, according to the records held by StatTraq

MostWanted lists the most popular posts on a wordpress powered weblog. This list can be used in the sidebar to provided visitors with an indication of what are the most visited pages.

The MostWanted plugin in use.It’s grown a little since it’s original release so it has a subtle API change. Where previously it was called “rjb_mostwanted”, it is now “MostWanted::mostwanted”. Currently there is a wrapper around the old method name so that it still works, however this will be removed in future releases.

Installation

  1. Download this fileDownload this file
  2. Rename it mostwanted.php and copy it to your /wp-content/plugins folder.
  3. using wp-admin, enable the plugin

Usage

The plugin provides one method of interest: MostWanted::mostwanted($top_n, $trim_chars, $showviews). The three parameters are:

  1. $top_n
    the number of results to list default = 5
  2. $curtail
    0 for no text curtailment, or ‘n’ the number of characters from each post title that shoudl be displayed. e.g. Curtailing “My Dynamic Badger” to 10 characters would read “My Dyna…”.
    default = no curtailment
  3. $showviews
    true if the number of times each post has been viewed should be included in the list.
    default = false
  4. $show_views_in_tt
    TT is short for ToolTip setting this value to true includes the number of views as part of the tool tip. i.e. if you hover over the text the (1234 distinct viewers) message is shown.
    default = true
  5. $duration
    restricts the duration of the query period so that only the last $duration days are considered when measuring popularity. e.g. a value of 30 would return the number of users only within the last 30 days. Leaving the value unset, or 0, results in the all-time results being returned.
    default = 0 (all-time)
  6. $pre
    this is a text string that is added to every line.
    default = <li>
  7. $post
    this is a text string that is added to every line.
    default = </li>
  8. $method
    there are two ways of identifying unique visitors, neither of which are perfect, the default is to recognize only unique IP addresses, which means that if several people from one company visit, then they may show as a single user. Alternatively, using the session_id is not perfect because some users refuse to set cookies.
    default = ip, alternative = session
  9. $as_percentage
    if set to true, then the number of hits for each page as a percentage of the site total is displayed instead of the hit count itself. This may be desirable if you want to show popularity without letting on how many hits you get for each story.
    default = false
  10. $timeout
    adjusts how long the most-wanted information is cached for before being replenished from the db. A value of 0 (zero) will result in fresh data being retrieved for every query, whereas a value of 3600 will only query the database once every hour, cacheing the output and thus reducing DB load.
    default = 1800

The simplest way to use the plugin is therefore to augment your page with:
<ul>
<?php MostWanted::mostwanted(); ?>
</ul>

A more tuned version might read:
<ul>
<?php MostWanted::mostwanted(7, 30, true); ?>
</ul>

License

MostWanted is released under a Creative Commons License.

Credits

If you find MostWanted useful, please feel free to link or a trackback to this entry.
Thanks to everyone whose commented with problems, solutions & suggestions, especially:

207 Responses to “MostWanted - a Popular Posts Plugin for WordPress”

Pages: «167891011121314151621»

  1. 101
    Scott Says:

    Ohhh, I always love replies that point out information that should actually help fix a problem!

    From the info you gave me and after doing a quick search of the Wordpress support forums, it just looks like a WP issue itself, so not related to the plugin. Well, maybe to the StatTraq plugin, but not the MostWanted one ;)

    Thanks again for the info. I’ll try out the code fix and if that doesn’t work, then I’ll give Michelle’s code a try.

  2. 102
    Scott Says:

    Hey Rich, I’ve been meaning to drop by with a quick reply for the past few days. Regarding the gzip compression error in Wordpress and the WeblogTools.com fix, it works, but doesn’t sort of.

    If you put the fix:
    php_flag session.use_trans_sid off

    In the index.php code as suggested, it has no effect. It does not work and this has been confirmed by multiple users on multiple themes.

    If you put it in your .htaccess file, it seems to break the newest version of Wordpress. At least it does for me.

    BUT!

    If you create and place the code in a file named, “php.ini”, and place it in your blog’s root directory, then it will work.

    So again for anyone else with this problem - create a new file called “php.ini” and have that in your blogs root directory. In the newly created php.ini file, put in the following(minus the quotes): “php_flag session.use_trans_sid off”

    Save/upload the file and you should be set!

  3. 103
    Rich Tatum Says:

    Hi, I’m using WP 1.5.2, MostWanted 0.1.8 (according to the PHP file), and StatTraq 1.0a. I’ve run the configuration fixstats, I’ve inserted Michelle’s code and I’ve modified lines 25 and 26 in the StatTraq php file to read:

    if (($post->ID != ‘’)){
    $p = intval($post->ID);

    However, I’m still getting the “no results available” message. I’m using permalinks in the form of:

    http://DOMAIN/blog/index.php/yyyy/mm/dd/slug/

    Any other clues? You can see my “Most Wanted” links at the top of my blog, beneath the header logo.

    Regards,

    Rich
    BlogRodent

  4. 104
    tommy Says:

    Any chance you can create a “most emailed” version of this plugin to work with skippy’s subscribe2 plugin?

  5. 105
    Rich Says:

    RichT,
    From what I can see of Michelle’s code, there doesn’t appear to be a reason for changing lines 25+26 as well. Have you tried using it without that alteration?

  6. 106
    Rich Says:

    Tommy, a nice idea which I’d not considered (because i’m not using Skippy’s plugin) so if you (or anyone else) would like to submit a patch I’ll include it. The solution would just need a different SQL query.

  7. 107
    Chris Frazier Says:

    I’ve got a couple of sites that use MostWanted, and have run into Dan’s problem with the PHP error “cannot be called statically”. Checking out the PHP 5 manual (this is only a PHP 5 problem) I found this:

    http://us2.php.net/manual/en/language.functions.php#44189

    Since this is obviously an architecture issue and not a simple bug-fix, is there any chance of getting an update for us sad-sacks stuck with PHP 5 on our hosts?

  8. 108
    Anders Wallin Says:

    I’ve maybe found a bug:

    I want to have both a listing for both last 30-days and all-time in my sidebar.
    I use the code:
    Popular Posts: last 30 days

    ‘,”,ip,false,0); ?>

    Popular Posts: all-time

    ‘,”,ip,false,0); ?>

    when I have them this way it does not work correctly, i.e. the all-time list is identical to the 30-day list.
    when switching the order of the function calls, first with duration=0 and then with duration=30 it works OK…

  9. 109
    dpetereit Says:

    finally the same prob Chris Frazier has described.

    at first I didn´t get the plugin to work at all because of the browser-issue. The whole sourcecode turned up to be shown on the plugins-page. i fixed that.

    then i ran into the header-issue. fixed that.

    afterwards i ran fixstats.

    now i got the “cannot be called statically”-prob. i tried to understand the php5-manual-workaround but didn´t manage to.

    as php5 should not be that exotic in the wild i´d have thought that Rich would already have presented a solution… Sadly i was wrong.

  10. 110
    Rich Says:

    as php5 should not be that exotic in the wild i´d have thought that Rich would already have presented a solution… Sadly i was wrong.

    I think I’m flattered that you expect so much of me :) (but please note that I’m not a software development company, I’m just a bloke that is making the things he writes for himself available to others free of charge).

    I don’t have a server with PHP5 and I don’t have much free time, but I will be looking into it. If I can work out a fix I will publish it, if anyone else works it out, please submit it and I’ll make it available.

Pages: «167891011121314151621»