Why am I seeing “Call to undefined function get_header() in index.php on line 1”?


Why am I seeing “PHP Fatal error:  Call to undefined function get_header() in /sites/xxxxx.com/htdocs/wp-content/themes/[THEME NAME]/index.php on line 1” in my Apache error logs?



Some WordPress themes have an error in their header.php file that calls upon the main theme directory as the URL to load a stylesheet. Look for a line like this in the theme’s header.php (found under the Document Root in wp-content/themes/[THEME NAME]/header.php):

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" media="screen">

When the browser obeys and attempts to load the URL which is composed using the [unspecified] ‘stylesheet_url’ configuration variable, the theme’s index.php will get run instead, which attempts to call the standard WordPress function get_header(), which will fail, as index.php was not properly bootstrapped by WordPress. This will cause a 500 (Server Error) message to appear in the Apache access log, and the PHP error to appear in the error log.



Comment out this line from the theme’s header.php. Ask the theme developer to fix their header.php.

Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Twitter
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • StumbleUpon

Leave a Reply

Your email address will not be published. Required fields are marked *