Have you ever deactivated a WordPress plugin only to find that it broke your blog won ‘t load any longer?  This is most common when you have your plugins deactivated because you are upgrading WordPress. 

The reason this is happening is because many WordPress plugin authors provide the call to the plugin without using an “if”.  This causes the call to the plugin to break your page when the server goes to pull the plugin code and discovers it has been deactivated.  

This actually isn’t very difficult to fix, so I figured I would write a quick post explaining how to do so.    I’ll use the popular Related Posts plugin for my example.     Once you’ve downloaded and installed the plugin, you’ll need to place some code where you want the related posts to display.    The plugin author gives you the following code to use:

<?php related_posts(); ?>

As you can see, there is no if/then involved, so it will cause problems if you deactivate the plugin.   Here is how the code needs to look to avoid breaking your blog:

<?php if(function_exists('related_posts')) { related_posts(); } ?>

You just need to take the related_posts in drop it in there twice.   This way if you deactivate the Related Posts plugin, it won’t cause any problems. 

To avoid problems in the future, I recommend going through your plugin list and converting all your plugin calls to the above format.  

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

There Are 12 Responses So Far. »

  1. 1 Rocque
    Monday, June 2nd, 2008 at 10:30 pm

    Thanks for this article. Something broke my blog and I thought it was the Exec-php plug in when I upgraded to 2.5.1. One blog worked perfectly and the next blog won’t keep the same template as the “good blog”. The template keeps changing on its own back to the Kubrick template. I am totally lost as to why this is happening.

    Upgrade “good blog” perfect. Upgrade next blog using same procedures and disaster.

    Are there any suggestions?



Leave A Comment