WordPress Theme Development Tip
Working with the Theme Switcher plugin is an excellent way to develop themes behind the scenes using WordPress. Simply install the Theme Switcher plugin, upload your working theme template files, and enter the secret URL (something like, “http://domain.tld/index.php?wptheme=Perishable”, where “Perishable” is the theme name) to activate the new theme. Easy as pie.
So that’s the scenario, and I’m sure that many of you are familiar with it. I have been using this method for years with nary an issue. Until today. Uploading a new theme that I am working on for Perishable Press, I began with the two required files: “style.css” and “index.php”. I then added a header and footer file and began fleshing things out with some basic functionality and markup. So far so good.
Then, after getting the header.php, index.php, and style.css files properly configured, I uploaded the batch fresh and went to check on the scene in Firefox. Uh-oh, not good. The header and CSS were loading fine, but the index.php file was not being loaded. Instead of the index file that I had created, WordPress was delivering up the default theme’s index.php file. No matter what I tried — clearing the cache, logging in/out of admin, deleting and re-uploading files, swapping out template code, and everything else I could think of — I just couldn’t get the new theme’s index.php file to load.
Fortunately, persistence pays off. After taking a quick break, I came back to realize that I had yet to add any code to the footer.php file. Aha! That was it. For some reason, if WordPress detects a blank footer.php file, it will assume that something is wrong and serve the index.php, footer.php, and other missing files from the default theme. And, I haven’t tested this, but I assume that WordPress does this when any non-required template files are blank (e.g., sidebar.php, search.php, category.php, et al).
In any case, after slapping a few lines of code into the blank footer.php file, everything began loading as expected — the new index.php appeared and that hideous default index.php finally went bye-bye.