I am getting occasional (3-4 a month) errors in a log file on the various WordPress installations that I support. The full text is
[25-Sep-2011 09:02:01] PHP Fatal error: Call to undefined function get_header() in /home/<ACCOUNT>/public_html/wp-content/themes/<THEME NAME>/index.php on line 1
Doing the natural thing I Googled for a reason but didn’t find much that was informative. Most of the cases reported were where the user had stupidly inadvertently overwritten the root index.php with the one from their theme of the day. The best I found was ardemis who is one step ahead of me.
As he implies, at important step is to stop the message reaching the user’s browser because it reveals rather too much about your web server. This is done by including the call
ini_set('display_errors', 0);
before the get_header();
. This makes the message ONLY appear in the log file, which incidentally, can be found in the theme directory. He then goes on to describe a more sophisticated approach which you can read there if it suits your site. But why are they occurring? Is it search engine spiders or hackers probing the depths of your site.
I am having the same problem with no results.
Can you please email me the code for this script or please tell me in detail concerning this script?
What script? I think all the details are there.
I’m having the same issue as well. I have spent hours on this and am baffled. I have been able to prove to myself that it is a problem with the theme. This problem ONLY happens with the index.php file. I can remove the index.php file completely and the site still works because it never falls back to the index.php file based on the wordpress template hierarchy. Still, I would love to know what in the world is causing this.
It definitely has to do with the wordpress classes not being loaded / available / whatever when it attempts to parse the index.php file.
The annoying thing is that the error log gets written to every time the home page of the site is loaded.
I wish I had more to contribute to this than just “me too!”