Popularity Contest Plugin Fatal Error in WordPress 2.5, 2.6+
The Popularity Constest Plugin written by Alex King adds functionality to your Wordpress blog: it displays a list the most popular posts in your blog’ sidebar based on the post / category / archive views, comments made by visitors, trackbacks,…
At the time of the writting of this blog, the Popularity Contest Plugin in only compatible with Wordpress releases up to up to wordpress 2.3.1. That means, if you are using the newer versions of wordpress say 2.5 or or the latest release wordpress 2.6 for that matter, you should brace yourself for one or a few surprises when trying to use that plugin in your blog.
That is exactly what happened last night when I tried to activate in the admin panel of my client’s blog. I have been slapped with a PHP error message:
Plugin could not be activated because it triggered a fatal error.
That should not deter you from using this wonderful plugin. Here are the steps I took to solve the issue at hands:
Step 1
The first thing I did was to check on my local server for parsing error since my client’s web server does not display those errors for security reasons. The only error revealed to me was the include path of the wp-blog-header.php which should be
../../../wp-blog-header.php
instead of
../../wp-blog-header.php
because the calling file pouplarity-contest.php is 3 folder levels down from the blog root folder where the wp-blog-header.php is.
Step 2
I made that correction then run the file (pouplarity-contest.php) again in my localhost server.
This time I only receive a database connection error. Good! No PHP parsing error.
I then uploaded the “pouplarity-contest.php” file to the remote server, went to the plugins section of the blog admin panel and tried once more to activate that plugin.
Not a chance, same fatal error message on my face. Grrrrr!!!.
Mind you, I have the utmost respect for the PHP developers (I am a member of that tribe) devoting their time to develop various applications and widgets they freely give to the online community.
Step 3
I commented out any add_action call and tried again to activate that Popularity Contest Plugin. No luck again, same fatal error message.
Step 4
I stopped for a few seconds, looked again then told myself: “the wp-blog-header.php file is already called somewhere by the admin header section with the require_once() PHP function!”
Solution:
* Remove or comment out (// or /* ….. */) the line 59 or whatever line contains the code:
require('../../wp-blog-header.php');
Tried again to activate the Popularity Contest Plugin.
This time it works!!
I can now use the akpc_most_popular() function in my blog sidebar to display the most popular posts.
I just save you time and frustration.
Now go ahead and
- make that change in the PHP code
- upload the file
- activate the plugin
.. and happy blogging!
Related Posts
Email This Post
| | Sphere: Related Content

September 13th, 2008 at 10:49 am
THANK YOU! This fix worked perfectly for me - took me an hour and I still didn't figure out the require_once() problem. Someone should let Alex King know that the @require is now deprecated.