DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Do you ever wished to be able to list your top contributors without using a plugin? If yes, you’ll be happy with this recipe that will show you how to do it.

Simply paste this code where you want your top contributors to be displayed. Note that this code use the mysql_* functions instead of the $wpdb object. This is not the better way to do this, but it do the trick 😉

mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

$sql = "SELECT
    . "FROM
    . "WHERE ".$table_prefix.posts.".".post_parent."=0
    . "Group by
    . "Order by count(*) DESC\n"
    . "Limit 0,10"; 
$result = mysql_query($sql) or die(mysql_error());
echo "\n";
echo "<ul>";
while($row = mysql_fetch_array($result))
    echo "<li><strong>";
    echo $row['user_login'];
    echo "</strong>&nbsp";
    echo "(";
    echo $row['count(*)'];
    echo ")</li>";

echo "</ul>";


This recipe has been submitted by Sidou. Do not hesitate to send me your recipes if you want them to appear on my site!


One Comment

  1. Thanks for sharing this. Is this going to work in a sidebar widget? I have the widget to display PHP!

Leave a Comment

Your email address will not be published. Required fields are marked *