WordPress Fatal error: Call to undefined function get_header() [fix]

Posted on July 6, 2015 in Web Dev

This problem seemed to come out of nowhere and was driving me crazy for at least 15 minutes.

This is the error message I was getting (I have redacted and edited a few directories of this for privacy):

Fatal error: Call to undefined function get_header() in /link/to/wordpress/install/public_html/wordpress_root/index.php on line 17

The problem was occuring on a pretty fresh install of WordPress via CPanel. I’ve never actually installed WordPress via CPanel before this, and similarly had never seen this message, so I could only assume I was doing something different wrongly.

The project was for a client of mine who had already bought hosting with 123-Reg. Usually I’d fire up a fresh VPS with Ubuntu on Digital Ocean for my clients, but this wasn’t one of those times as they’d already paid for a years hosting upfront. The downside to using shared hosting that you’re not already familiar with is that there’s always going to be a learning curve with regards to the UI and how to set everything up. This then eats into your profit as you’re spending more time learning something that you shouldn’t really have to. Which… Is kinda annoying. The good thing in this instance was that 123-Reg was actually pretty decent.

Anyway. The problem.

I had created 4 child themes which were going to be going on 4 separate installs of WordPress on the same server, different databases. Since this was shared hosting and I’d already spent quite a bit of time setting up the DNS and everything (something that takes me 2 seconds with DigitalOcean), I didn’t think it was worth finding out how to SSH into 123-Reg shared hosting (or if it was even possible), and then installing Git on there. Usually I deploy directly via Git (Bitbucket highly recommended), but due to me kinda cutting corners and already having over-serviced, I opted to deploy via FTP. It’s worth noting that I don’t anticipate any long terms changes with this client – once the sites are up they’ll pretty much be forgotten for eternity in terms of new changes being made etc. It’s not like I’m working on a startup that’ll be iterating always and pushing changes live every day.

I’d made a change to the parent theme’s index.php file. I wanted to push the change live quickly and then crack on with the next site. I pushed it live and 10 minutes later I noticed that the site was down and showing the message:

Fatal error: Call to undefined function get_header() in /link/to/wordpress/install/public_html/wordpress_root/index.php on line 17

After lots of Googling and Stack Overflowing (that’s now a verb, right?), I was unsuccessful in solving my problem. I decided to retrace my steps exactly for the past houst…

I realised that I replace the WordPress ROOT index.php with my themes updates index.php. BIG DIFFERENCE. So with Filezilla open I dragged my local parent theme index.php into the WordPress root, overwriting it. I obviously meant to drag it into the parent the file, but in my haste I just did it wrong.

That’s it. Simply check you haven’t overwritten any root files with files destined for your theme’s folder.

Leave a comment

Was this helpful? Did I miss something? Do you have a question? Get in touch, or tell me below.