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.  

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Follow Kyle on Twitter @KyleEslick!

  1. Rocque says:

    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?

  2. Mike says:

    Great tip.
    I have deactevted my related posts plugin, but my single.php pages still show related posts.
    There is no call on this page like

    Can someone help me get rid of my related posts?
    Could it be something’s still embedded in the mySQL database that generates the related posts?

    You can view my problem on my photography blog:

Trackbacks/Pingbacks »

  1. Guide to Making a Successful WordPress Theme · My Web says:
  2. What to Do If Plugin Deactivation Breaks Your Blog says:
  3. If deactivating a plugin breaks your blog — WP Project says:
  4. SURFTIN - How To: Prevent WordPress Plugins From Breaking Your Blog says:
  5. 100+ Killer Wordpress Resources | Steffan Antonas' Blog says:
  6. Best WordPress Plugins – Great List! « Josephbryanmedia's Blog says:
  7. How To: Prevent WordPress Plugins From Breaking Your Blog | artsinekart says: