Skip navigation

When the Blog Breaks: Fixing Your Broken Blog

In Part One of this two part article series, we explored how to determine when your blog or website is down and explored various monitoring and notification methods. In this part, we will look at what may break a blog, and offer suggestions on troubleshooting and fixing your broken blog.

What Can Bring Your Website or Blog Down?

There are many things that can effect a host server. Luckily, most hosts offer extensive backups and guarantees on “up time”, but not every server can work all of the time, every time. They will break.

From the host’s side of the blame, hard drives can crash, there can be an electrical outage, fire, virus, or some other calamity beyond the host’s responsibility.

Glitches happen. A problem might occur when a server drive is switched for a new one and it fails. Or the whole server may go down for some kind of maintenance. You never know. If you notice odd behavior or your site is down for more than an hour, and you cannot determine the cause from your end, then contact your site host.

From your side of the fence, there are many things that can bring down your website or blog.

Failure to delete a file before uploading its replacement via FTP. A drop in the connection signal, a hiccup in the process, or a minor glitch in the upload can mean a file is only partially uploaded to your site. Make sure you delete the original file before uploading the replacement to help the whole file make the process.

Even fresh replacement files may experience a glitch in the uploading process. Upload files in batches and check them before moving on to narrow down any specific files that might be corrupted through the uploading process. Compare file sizes and names to make sure they match. A minor glitch or interruption in the uploading process can leave behind an undone or partially uploaded file. And check carefully to make sure the new files you uploaded are in the right directory.

If you activated a WordPress Plugin, it may have a conflict with another Plugin or have an error in the Plugin code. Most WordPress Plugins come in a zip file with only one file and a readme file, or a folder containing all the necessary files. Upload it to your /wp-content/plugins folder and activate the Plugin from the Administration Panels. Other, often older, WordPress Plugins will require copying and pasting in the PHP code to a text file and then uploading that to your WordPress blog. A very common problem with this method is that there can be an unnecessary space or line break before or after the first PHP code at the beginning or end of the file before the last closing code element. Make sure all spaces are removed before the first <? php code.

If your site fails to load or displays the “Database Error” or “WordPress not installed” after uploading and activating a WordPress Plugin, then it may have a conflict with another WordPress Plugin or other code within your template files. Access your site through your FTP program and delete the new Plugin file(s) from the /wp-content/plugins directory and check your site again in your browser. It should work now. If not, remove the Plugins one by one until it does, moving each into a directory outside of the plugins directory for quick restoration. Be sure and do a total refresh to clear the browser’s cache, if necessary, to see the changes.

When you identify the culprit, or if you need help with a WordPress Plugin, contact the WordPress Plugin author first, before contacting the .

Failures with your WordPress Theme come in a variety of flavors. They begin with simple errors in the XHTML/HTML or CSS. Most of these are visible errors, like the sidebar moving below the post or the footer showing up in the header. They can easily be detected visually, or through validation tests to determine what went wrong.

Errors in your WordPress Theme most likely to bring your site down include errors in the PHP coding of the WordPress Theme and modifications to the WordPress Themes by changing PHP code, template tags, and/or adding WordPress Plugin template tags. These errors usually return the line on which the error occurred, unlike errors which return a blank screen. Double check the code and/or remove it to see if that is the culprit.

Deactivated WordPress Plugin is not found. If the page loads part way and reports a error in the PHP code at line X, this probably means the WordPress Plugin the WordPress Theme template file is looking for isn’t activated. Either activate the Plugin or wrap it in a conditional code. For example, for the Related Posts WordPress Plugin, the conditional statement looks like this, asking “If the Plugin is activated, do this action. If not, skip this.” The code for the Related Posts WordPress Plugin callout is related_posts, and the conditional statement would look like:

<?php
if (function_exists('related_posts')) {
echo ('<li id="recent">Related Articles<ul>');
related_posts();
echo ('</ul>');
}
?>

If the Plugin is deactivated, this entire section will not appear on the page, and no error is triggered. The page still loads.

Database errors can also cause problems. These can occur when you make manual changes to the database, or when a WordPress Plugin creates or modifies a table in your WordPress database, and it doesn’t quite work right. The latter can happen during the installation of a Plugin, or during the execution of a Plugin.

Discovering database errors isn’t always easy. A database error may be visible on your WordPress blog web page as a reported error when a Plugin or request from the database tables fails. Sometimes the error isn’t visible on your WordPress blog but found when you access your database through PHPMyAdmin causing you to not be able to access your database, a specific table, or you find a table’s content’s scrambled. Some of these errors can be tracked down and fixed, but others may require deletion and recreation of the table or the use of a table/database repairing utility, which may require assistance from your website host.

Again, if it is the Plugin, using an FTP program, remove it from your Plugins directory to see if that will fix the error first before attacking your database. And always backup your database and website before attempting any of these potentially “make-worse” efforts.

Finding the Troublemaker

In my article on Finding Your CSS Styles in WordPress, I offer a technique for helping to find problems with your WordPress Theme stylesheet. This technique can also be used to narrow down problematic code in your WordPress template files.

Backup your WordPress site, database, Plugins, and WordPress Themes before you begin this process. Put the backup in a safe place as you may need it.

Begin with the template file causing you the problem. It is probably the index.php or single.php template files. Make backups of your WordPress Theme before you begin.

Most errors report which line the error is on. With WordPress, line 220 could be anywhere since WordPress Themes use a modular system for generating WordPress web pages. Line 220 means adding up the lines in the blog header, Theme header, body templates (index.php or single.php for example), comments template, search template, sidebar template(s), footer template, and any other modular template files, and finding out which code is found on line 220. Messy.

If you do get a line error, then view the generated page’s source code to determine approximately where the error is occurring. Using a quality text editor program with line numbering, you can copy and paste the source code and go down the line numbers to track down 220. The error might be on 219 or 221 or something close, but it puts in you in the area. Once you track down the area, open the template file in your WordPress Theme that contains that section of code and start troubleshooting there.

If there is no clear indication of which line the error is on, then you need to start troubleshooting the templates one at a time.

With the first possible problem template file in a text editor, start from the bottom of the file and highlight the reference to the footer code and choose one of the following methods for removing this code element from the web page generation process:

  1. Select the code and choose CUT from the menu or Ctrl+X to put the code into your computer’s clipboard.
  2. Comment out the code so it will not function. With HTML/XHTML tags, you can wrap them in comment tags to hide the code:

    <!-- <p>This is some commented out text.</p> -->

    To comment out PHP code, find the beginning of the PHP code command and put two forward slash marks just after the PHP tag:

    <?php // include('footer.php'); ?>

Once you have commented out or removed the code from the template file, save the file and upload it to your site’s WordPress Theme directory. In your browser, do a complete refresh to view the page again and see if the problem is fixed. If it is, the error is in the footer.php template file.

If not, go back to the copy of the file in your text editor and either click Ctrl+V to paste the code back in place, Ctrl+Z to undo the removal of the original code, or remove the comment codes to reactivate the code section.

Move up to the sidebar callout for your template file. It usually looks like:

<?php include('sidebar.php'); ?>

Repeat the CUT process and save and upload the changed template file and test it. If the problem goes away, then the problem is in your sidebar.php. If not, put it back and proceed on to the next section.

I recommend that you repeat the CUT process with the header before moving onto the post content section.

If these don’t work, then you will need to go through, code by code, each section very carefully in your post content section, removing it line by line and code grouping by code grouping, to see what may be causing the error.

To narrow down the troublemaker in the different template tags or sections, begin by looking for Plugin template tags within the area. These are usually the problem. If they are not, then carefully go through each line of code and look for errors. Each PHP code begins with <? and ends with ; ?>, so make sure those are there. A left off semi-colon or question mark can kill your code.

The WordPress Codex features an extensive list and examples of the most common WordPress Template Tags. Use this as a reference to check you have put every element in the template tags in your WordPress Theme and that they are right, every comma, period, quote, apostrophe, colon, semi-colon, and question mark.

If All Else Fails, Search Then Visit the WordPress Support Forum

If all else fails, search the web to find out if anyone else has solved your problem.

Then turn your search towards the WordPress Support Forum. The problem with searching for help, whether on the web or WordPress Support Forum is finding the words to help you find the help you need. My article on First Step to WordPress Help: Search First will help you determine how to search for the help you need with WordPress errors.

Remember, before you do, SEARCH FIRST. Most of the time, people have run into similar problems and you may find the answer on the Forum or by searching the net.

For more information on how to get the help you need for WordPress and how to use the WordPress Support Forum, read:

When the Blog Breaks You Fix It

Hopefully now you have a better idea of how to monitor and fix your broken blog. Any other suggestions? How do you monitor and fix your blog when it breaks?

Related Articles

BlinkList | Blogmarks | Digg | Del.icio.us | Ekstreme Socializer | Feedmarker | Furl | Google Bookmarks | ma.gnolia | Netvouz | RawSugar | Reddit | Scuttle | Shadows | Simpy | Spurl | Technorati | Unalog | Wink | Yahoo MyWeb2


Site Search Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Copyright Lorelle VanFossen, member of the 9Rules Network

Member of the 9Rules Blogging Network

7 Comments

  1. Posted August 1, 2006 at 10:50 pm | Permalink

    Another problem may come about when upgrading. I did not give enough time yesterday to troubleshoot. I ended up having to back out, delete the database and upload the saved db.

    What a pain. I’ll give myself more time when I attempt it again.

  2. Posted August 1, 2006 at 11:36 pm | Permalink

    Two great posts Lorelle. Both are book marked before the next time i try upgrading or changing anything!

  3. Posted August 2, 2006 at 4:15 am | Permalink

    Tremendous and very helpful post, Lorelle, thank you.

  4. Posted August 2, 2006 at 4:22 am | Permalink

    A friend of mine had problems with her wp feed, a plugin caused the failure.
    After deleting the plugin, everything works fine now.

  5. Posted August 2, 2006 at 4:53 pm | Permalink

    Actually, I’ve noticed the single most common problem with “breaking” wordpress is the careless insertion, or deletion, of a single quotation or bracket () — which either incompletes an open bracket, or opens a new bracket with PHP.

    Whether its rolling your own PHP, or inserting bits of code into different themes, it can either make your blog go blank if the error is high enough, or not show anything at all below the level of the error.

    Its enough to make you tear your own hair out, as you’ve got to debug character by character.

  6. Anonymous
    Posted June 8, 2009 at 6:45 am | Permalink

    What can I do when I made a mistake/typo in the theme’s functions.php? The complete blog is inaccessible. I think this is WordPress’ biggest bug.

    No other way than edit functions.php via ftp?

    • Posted June 10, 2009 at 5:37 pm | Permalink

      First, ftp to the site and rename the functions.php. Find the backup original or a different version and upload it. Should be fixed.

      If you cannot get access to the Administration Panels, or the FTP, you’re sunk. If you can get to the Administration Panels, you can use the Theme Editor under Appearance. Good luck.


16 Trackbacks/Pingbacks

  1. [...] can swallow a pint of blood before you get sick. « Crank the movie by milo Helpful advice Lorelle wrote a very good and helpful advice, if your wp blog/site is broken, see broken blog, orcss styles. advice» blog» broken blog» bug fix» css styles» lorelle» updates and news» [...]

  2. [...] When the Blog Breaks: Fixing Your Broken Blog [...]

  3. [...] When the Blog Breaks: Fixing Your Broken Blog [...]

  4. [...] When the Blog Breaks: Fixing Your Broken Blog [...]

  5. [...] When the Blog Breaks: Fixing Your Broken Blog [...]

  6. [...] Fate also dictates that the morning after, I notice Lorelle’s great post on fixing a broken theme. [...]

  7. [...] When the Blog Breaks: Fixing Your Broken Blog and My WordPress Theme is Broken to help troubleshoot your WordPress blog, and always check the [...]

  8. [...] When the Blog Breaks: Fixing Your Broken Blog [...]

  9. [...] When the Blog Breaks: Fixing Your Broken Blog [...]

  10. […] When the Blog Breaks: Fixing Your Broken Blog […]

  11. […] When the Blog Breaks: Fixing Your Broken Blog […]

  12. […] a Plugin is active is wrapped around every Plugin statement breaking your blog’s Theme. See When the Blog Breaks: Fixing Your Broken Blog for the instructions on what to do when Plugins break your WordPress […]

  13. […] When the Blog Breaks: Fixing Your Broken Blog […]

  14. […] When the Blog Breaks: Fixing Your Broken Blog […]

  15. […] When the Blog Breaks: Fixing Your Broken Blog […]

  16. […] When the Blog Breaks: Fixing Your Broken Blog […]

Post a Comment

Follow

Get every new post delivered to your Inbox.

Join 20,668 other followers

%d bloggers like this: