The Secret to Debugging Code: Blog Template / Theme Problems
For the past couple of weeks I’ve been taking advantage of my hiatus from blogging to concentrate on finishing minor tweaks that were necessary to my template / theme.
You might not have noticed, and although these changes may seem relatively minor they are in fact fundamentally important to the design. They were also more difficult to accomplish so I had not bothered to implement them until now.
For example, I moved the MyBlogLog widget over to the sidebar where it belonged. That was the easy part.
I wanted to replace the block by showcasing more of my recent posts with one easy glance on the main page just below the video. The hard part was how to accomplish it and not duplicate the same posts that are shown in the left column. I eventually accomplished it with the help of a plugin.
Funny thing was the next day I noticed some unusual things happening on the post pages. The post was being truncated at the end of the sidebar! Hmm, and to make matters worse it was only happening in IE!
I hadn’t noticed the problem the day before because I made the changes late at night. I like to do template changes at night because that’s when there is less activity on the blog. I was tired at the time and wanted to get to bed so I hadn’t bothered to test it properly. Big mistake!
So the next day I disabled the plugin thinking that would solve the problem, but it was still acting up. Stink!
Because I didn’t notice this until the next day I had temporarily forgotten that I had also moved my statistics tracking code from my header to the bottom of the sidebar. Must be that alzheimer’s thing again. So could that be it?
I removed the code and it was working fine again! After experimenting around a little I eventually decided to put the code into my footer imemdiately before the </body> tag. My rationale was is if it truncated the post there it wouldn’t really matter because that was the end of the page anyhow.
So guess what? You guessed it, all is working well again!
The most important thing that I want to get across in this post is that you should NOT make too many changes at one time. Make just one change and then take your time testing it. Give it at day or so to play around with it before you decide to make any more changes.
Click on all of the links and notice if anything looks strange or out of place. Check it out on the main page as well as the post pages. Scroll all the way down and back up again carefully scrutinizing everything.
Test it in the major browsers like Internet Explorer, Firefox, Opera and Safari. If all looks good, then you can save a backup onto your desktop and make more changes if you want.
But if there is a problem, backtrack over what you recently did. Or in other words take a step backwards by reverting your template back to what it was before you made the last change that screwed up.
Maybe that would entail disabling that last plugin you installed. Or perhaps it’s your code that you messed up. Disabling a plugin is easy, but if it’s your code then it’s probably just a minor syntax error.
For example, perhaps you made some changes to your CSS code. You were trying to indent a paragraph and all hell broke loose. Then just Google and chances are you will find the fix you need.
But if worst comes to worst and you still can’t figure out what went wrong, restore that last backup you made from your desktop. Test it again. If it looks normal then you know it was that last change you made.
BUT the important message here is you should NOT make too many changes at one time. Why? Because it will be harder for you to backtrack and remember what you did that caused the problem in the first place.
Baby steps baby…
UPDATE: Then again sometimes all hell can break loose. After further investigation it’s become clear that I am suffering database issues that are not repairable. I’ve contacted my blog host provider and they will be transferring this blog to a fresh install of Wordpress. So things may be acting even more strangely today. Stay tuned…