While making changes to my WordPress theme, I noticed that the error_log file in my theme folder contained dozens of PHP Fatal error lines:
... [01-Jun-2011 14:25:15] PHP Fatal error: Call to undefined function get_header() in /home/accountname/public_html/ardamis.com/wp-content/themes/ars/index.php on line 7 [01-Jun-2011 20:58:23] PHP Fatal error: Call to undefined function get_header() in /home/accountname/public_html/ardamis.com/wp-content/themes/ars/index.php on line 7 ...
The first seven lines of my theme’s index.php file:
<?php ini_set('display_errors', 0); ?> <?php /** * @package WordPress * @subpackage Ars_Theme */ get_header(); ?>
I realized that the error was being generated each time that my theme’s index.php file was called directly, and that the error was caused by the theme’s inability to locate the WordPress get_header function (which is completely normal). Thankfully, the descriptive error wasn’t being output to the browser, but was only being logged to the error_log file, due to the inclusion of the ini_set(‘display_errors’, 0); line. I had learned this the hard way a few months ago when I found that calling the theme’s index.php file directly would generate an error message, output to the browser, that would reveal my hosting account username as part of the absolute path to the file throwing the error.
I decided the best way to handle this would be to check to see if the file could find the get_header function, and if it could not, simply redirect the visitor to the site’s home page. The code I used to do this:
<?php ini_set('display_errors', 0); ?> <?php /** * @package WordPress * @subpackage Ars_Theme */ if (function_exists('get_header')) { get_header(); }else{ /* Redirect browser */ header("Location: http://" . $_SERVER['HTTP_HOST'] . ""); /* Make sure that code below does not get executed when we redirect. */ exit; }; ?>
So there you have it. No more fatal errors due to get_header when loading the WordPress theme’s index.php file directly. And if something else in the file should throw an error, ini_set(‘display_errors’, 0); means it still won’t be sent to the browser.
i was upgrading my website and i recieved this message. Fatal error: Call to undefined method Arras_Widget_Tag_Cloud::WP_Widget_Tag_Cloud() in /home/deebeamc/public_html/wp-content/themes/arras/library/widgets.php on line 404. pls can anyone help me out here. it is not allowing me to log on to word press again
Use an FTP client to connect to your web host.
Upload the Arras theme again to /wp-content/themes/arras/.
If that doesn’t work, navigate to your /wp-content/theme/ folder and delete the /arras/ folder. This should allow you to access your site again. The problem seems to be with a widget in that theme.
You’ll have to upload the Arras theme again, or use a different theme.
Thats what happened to me too. Trying to fix it now but I dont know anything about what an FTP Server is 🙁
Guys,
The “Fatal error: Call to undefined method” or “Fatal error: Call to undefined function” messages that reference one of your theme’s files or one of your plugins, are coming from that theme or plugin. The easiest way to get your site working again is to use an FTP client to connect to your site and delete the theme’s folder in /wp-content/themes/ or the plugin’s folder in /wp-content/plugins/.
If you don’t know what an FTP client is, then you should ask someone you trust to help you.
i have a get_header() error on my 404 page, any ideas on how to fix it? i use the theme arclite…
@jake: I have the same problem; only occurs on the 404 page. Shouldn’t really matter, but I’m using my .htaccess to redirect 404 errors to my 404 page… In the htaccess file, I spelled out the dir path to the 404.php in my themes directory. If anyone finds a solution, please let me know cause I four sites that are currently affected by this 🙁
Found the solution at http://discussion.dreamhost.com/thread-25645.html. This only applies to some web hosts (Dream Host, GoDaddy and others; not the actual good hosting companies like mine, lmao). Edit your .htaccess file so that instead of “ErrorDocument 404 /wp-content/themes/theme_name/404.php” it reads “ErrorDocument 404 /index.php?error=404” and it will redirect the visitor to your 404 page. 😀
ur little piece of code did the trick for me! thank u so much! 🙂
very thanks problem resolved get_header()
I have the problem of the same it says
Fatal error: Call to undefined function get_header() in /home/s/u/ftp_sumondodk/wp-content/themes/child-zerif-pro/index.php on line 14
but i haven’t done anything to the index.php
i wrote that piece of code but didnot work. i am using Zerif pro theme….please help
header(“Location: http://” . $_SERVER[‘HTTP_HOST’] . “”); could you write it more detail please
Hy ardamis,This problem is occur in my wordpress header.php please guide me how I can solve this
“Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”