Physician Heal Thyself: When WordPress Themes go Bad

Just had an irritating couple of hours when I discovered that my WordPress Theme was broken. The sidebar had slipped to underneath the main column, and the background of the main posting area had disappeared. I tried clearing my cache first of all. Then I tried looking at the site in different browsers. It was still broken in IE: although the symptoms were slightly different the sidebar was still misplaced.

OK, time to roll my sleeves up …

I got into the admin interface and tried a few different themes. Now it was getting interesting … it was present on all themes, which means that an upgrade must have altered something in the main code. Some searching around on the WordPress forums didn't reveal the clammour of angry WP users I was expecting, so I was reduced to searching for generic solutions.

In one post in the darkest corners of the internet I found someone suggesting that a <div> tag wasn't closed properly. That made sense, so I downloaded the source code for the page and edited that. It seemed that adding a </div> tag immediately before the code which calls the sidebar does the trick. Like this:

<?php get_sidebar(); ?>


<?php get_sidebar(); ?>

Now the challenge was finding that code. I went into the theme editor and tried a few files (header.php, footer.php and page.php)  before I found what I wanted in the Main Index (index.php). Making the change was the work of seconds and reloading the page meant I was back to normal. You may find this code in different places depending on which template you're using. In another template I found the code in the footer.php file, and in this case the closing </div> tag was present, but just appeared before the get_sidebar code. The fix for this was just to reverse the two tags.

OK all good. But what actually caused it in the first place? I haven't altered anything in the templates for several months; after the last upgrade I did, a month or so ago, everything seemed to be OK; after the last post a week ago, everthing seemed to be OK. Strange. And Broken.

Leave a Comment