One of the most popular plugins out there for WordPress is the Popularity Contest Plugin by Alex King. This plugin ranks the popularity your posts by pageviews, trackbacks, comments, etc and displays a popularity value at the bottom of the post.

Popularity_Percent.JPG

It also allows you to put a list of “Most Popular Posts” on your sidebar.

Getting_Popular_Post_to_appear.JPG

Unfortunately, WordPress 2.5.1 users get a fatal error when trying to activate the plugin. The good news is, it’s a fairly easy fix, especially if you were using the plugin in a previous version of WordPress. If you weren’t using the plugin before upgrading or installing WordPress 2.5.1, the fix is a bit more involved, but still doable. Please note, this fix isn’t my own. I learned about it here. I’ve rewritten the steps to hopefully provide a clear step-by-step account of the process (complete with screenshots for those of us who like pictures).

Ok, if you had been using Popularity Contest in a previous version of WordPress, and it no longer works now that you’ve upgrated to WordPress 2.5.1 - the fix is as simple as changing 1 line in the popularity_contest.php file. Open the file in a text editor like notepad (when you save the file, remember to save it with the .php extension, not the .txt extension).

Open popularity-contest.php and scroll down to line 59. Replace require(’../../wp-blog-header.php’); with require(’../wp-blog-header.php’);

You can also download a patched version of Popularity Contest, as well as read a more detailed description of this fix by visiting here.

Now, if you’ve never used Popularity Contest before and you’re trying to install it now on WordPress 2.5.1 you’ll still get a “Fatal Error” message when you try to activate the plugin. That’s because you need to some database modification to get it to work.

Again, this issue is discussed in greater detail here, my goal with this post is to provide a set of screenshot instructions detailing how to create the two database tables necessary in phpMyAdmin for Popularity Contest to run. I host with GoDaddy, so my screenshots will be perfect for anyone else hosting with GoDaddy. If you’re not hosting with GoDaddy, you’re on your own. Hopefully the steps will be similar. When in doubt, call your hosting provider.

  • Navigate to phpMyAdmin. If you’re hosting with GoDaddy, go to: Hosting and Servers > My Hosting Account > Manage Account.

Manage_My_Hosting_Account.JPG

  • Click on the Databases Tab > MySQL

Click_on_Databases_Tab.JPG

  • Click on “Open Manager”. Your username for the next screen will be the same as your Database name. If you’ve forgotten your password you can click the pencil icon (circled in black) to change your password.

Open_Manager.JPG

  • Once you’ve successfully logged into phpMyAdmin, click on the SQL button to create the tables needed for Popularity Contest.

Click_on_SQL_button.JPG

  • Paste the following text into the popup window and click “Go”. Note: If you’re running multiple copies of WordPress on the same database, please read the details here about changing the ‘wp_…’ portion of the text below. If you’re running a standard install of WordPress, don’t worry about it and proceed.

CREATE TABLE IF NOT EXISTS `wp_ak_popularity` (
`post_id` int(11) NOT NULL,
`total` int(11) NOT NULL,
`feed_views` int(11) NOT NULL,
`home_views` int(11) NOT NULL,
`archive_views` int(11) NOT NULL,
`category_views` int(11) NOT NULL,
`single_views` int(11) NOT NULL,
`comments` int(11) NOT NULL,
`pingbacks` int(11) NOT NULL,
`trackbacks` int(11) NOT NULL,
`last_modified` datetime,
KEY `post_id` (`post_id`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS
`wp_ak_popularity_options` (
`option_name` varchar(50) NOT NULL,
`option_value` varchar(50) NOT NULL
) ENGINE=MyISAM;

Paste_the_code_and_click_go.JPG

After pasting the text and clicking “go” you should see a screen that looks like this stating that your “SQL Query has been executed successfully:

Query_Executed_Successfully.JPG

Pop back over to WordPress and try to activate the Popularity Contest Plugin. That’s it! If you have any problems, be sure to visit here. Again, these steps aren’t my own fix, but I thought a step-by step guide with screen shots documenting the process I went through to fix the plugin might be helpful for others.

EDIT: after publishing this post I discovered another patched version of the plugin from yellowup.com here that doesn’t appear to require any changes to your database. I haven’t tried it (I didn’t want to break my currently working plugin to see if this one works), but a few people on yellowup.com have commented that it works. Give it a shot and let me know if it works for you.

Popularity: 20% [?]