Custom Theme Redirects to Active Theme In Live Preview

Hi there,

I’m attempting to build my own WordPress theme from scratch. The only code I am using to build this theme are pieces taken out of the official WordPress codex as well as a tutorial linked to by the codex site.

The problem:
While the first page in live preview loads fine, everything I click on simply uses my current theme (Twenty Twelve) instead of the template files I’ve uploaded in the them. Since it’s for everything from single posts to pages, I’ve narrowed my troubleshooting focus on page.php and getting that to work as I figured that would be less complex than single.php.

Building the theme:
I’ve uploaded all of the necessary files as per the file structure of a WordPress theme (index.php, style.css, header.php, footer.php, sidebar.php, page.php, single.php, etc.). The code I’ve used is extremely basic that I could tell simply because I’m new to coding a WordPress theme (I know HTML and CSS quite well).

Diagnosing the problem (Live preview):
Initially, I thought it may be an issue with live preview. So, I tested another theme that came bundled in with WordPress in live preview and tested a page. The page loaded fine. So, I’ve ruled out the live preview feature.

Diagnosing the problem (page.php):
Naturally, I thought that page.php might be the problem. I had trouble finding out what was required in the page.php file itself other than to make sure to put the basics in (basic functions to get the sidebar, header, footer, the loop, etc.). So, I built a page.php with those elements in there. Problem persisted.

One solution in getting the file to work that I found was to copy and paste the code I built in index.php and insert that into page.php. Problem persisted.

Another solution I came across was to copy code from another functioning theme and paste that into page.php. While it ran the risk of looking wrong, the goal was to actually get page.php to work. Pasted the code from Twenty Twelve into page.php. Problem persisted.

Finally, I just inserted the word “Test” into the file and tried that. Problem persisted.

Since the problem persisted regardless of what was put into page.php, I’ve ruled out page.php being the culprit.

Diagnosing the problem (index.php):
The only other component that could possibly affect this file is index.php. I’ve commented out small sections of the code to see if that resolved the problem. I got to the point where I commented everything out and simply created an HTML link so I could test a page. Problem persisted.

So, if the problem persists regardless of what is used in index.php, then the problem clearly does not lie in index.php either (since header/footer/sidebar was commented out in the process, it can’t be those files causing the problem either.)

Diagnosing the problem (style.css):
Since CSS is actually something I know, I looked over my style.css file and nothing in there links to anything outside the theme. All there is are a few rules that create containers with grey boxes around them. So, I’ve ruled out style.css.

Diagnosing the problem (plugins):
I have minimal plugins installed. In fact, I deliberately left all caching plugins disabled in the process of all of this. The only ones activated are antispam (Akismat), an XML Sitemap plugin, and Yoast for SEO. None of the three would necessarily affect themes in this manner to my knowledge. So, I’ve ruled out a plugin causing the issue.

Diagnosing the problem (absense of home.php):
Going back to the hierarchy, I know that some themes use a home.php file. Thinking that maybe there is something wrong with the structure that disallows linking to pages from index.php, I copied the code from index.php into a new file (home.php) and reuploaded the theme (after deleting the old version from WordPress of course). The home.php file loads instead of index.php (inserted text to make it obvious that it worked), but the problem still persists.

Diagnosing the problem (WordPress):
I use Dreamhost to update WordPress for me. It’s the latest version of WordPress. So, it can’t be a faulty install (I’m pretty sure I would see problems a lot sooner if it was). I quickly scanned through changelogs to see if theme development would be affected by 4.0, but failed to find anything. So, there’s a strong case that I could rule out WordPress.

Diagnosing the problem (Dreamhost):
I couldn’t find anyone else having similar issues, so I’ve ruled out a hosting issue at this stage.

So, at this stage, I am unable to find a way of resolving this issue since I’ve, well, ruled out everything that could cause this problem and I’m out of ways I can fix this problem. I’m wondering if anyone is aware of why WordPress would redirect my theme templates to Twenty Twelve in live preview? If so, is there something specifically I need to do with the php code to prevent this redirect?

Alternatively, is there a particular guide I could follow that works with WordPress 4.0 on Dreamhost?

Edit: I should probably note that at no point in this whole process was this problem not present to my knowledge.