• Resolved kungfuvn

    (@kungfuvn)


    When I access my site at https://mysite.com/wp-content/themes/mytemplate/

    Error message:

    Fatal error: Call to undefined function get_header() in wp-content/themes/alltemplate/index.php on line 1

    I have tried with all my theme at wp-content/themes/mytemplate1/ and wp-content/themes/mytemplate2/ and more

    I got the same with site offline error message :

    Fatal error: Call to undefined function get_header() in wp-content/themes/mytemplate1/index.php on line 16
    and
    Fatal error: Call to undefined function get_header() in wp-content/themes/mytemplate2/index.php on line 17

    and more

    How to fix it,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kungfuvn

    (@kungfuvn)

    This is hosting error, I contacted my hosting service and the hosting answer is a regular error ???? hostgator

    I GG search How to fix the “PHP Fatal error: Call to undefined function get_header()” error in WordPress

    And the search results :

    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:

    1 …
    2 [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
    3 [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
    4 …

    The first seven lines of my theme’s index.php file:

    1 <?php ini_set(‘display_errors’, 0); ?>
    2 <?php
    3 /**
    4 * @package WordPress
    5 * @subpackage Ars_Theme
    6 */
    7 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:

    1 <?php ini_set(‘display_errors’, 0); ?>
    2 <?php
    3 /**
    4 * @package WordPress
    5 * @subpackage Ars_Theme
    6 */
    7 if (function_exists(‘get_header’)) {
    8 get_header();
    9 }else{
    10 /* Redirect browser */
    11 header(“Location: https://&#8221; . $_SERVER[‘HTTP_HOST’] . “”);
    12 /* Make sure that code below does not get executed when we redirect. */
    13 exit;
    14 }; ?>

    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.

    source : https://www.ardamis.com/2011/06/02/fix-for-php-fatal-error-get_header-in-wordpress/

    I am also with hostgator and have similar error log under wpcontet/themes/decorum but it says:

    Call to undefined function get_header() in /home2/kenya/public_html/mysite.com/wp-content/themes/decorum/index.php on line 1

    Somebody can help how to fix this?

    @jronder: If you require assistance then, as per the Forum Welcome, please post your own topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fatal error: Call to undefined function get_header() in wp-content/themes/’ is closed to new replies.