Call to undefined function get_header()

Posted in: Newspaper
Post count: 45

Hello, my site is running normally, but i can see this error in apache linux error.log file.

[Thu Aug 11 22:16:21 2016] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function get_header() in /var/www/mysite.com/public_html/wp-content/themes/Newspaper/index.php on line 6, referer: http://www.mysite.com/wp-content/themes/Newspaper

I can fix it using with:
<?php
if ( function_exists("get_header") ){
echo "The code";
}else{
echo "Show error";
}
?>

But if i do this, in the next update this will be overwritten.

Thanks.

Post count: 7909

Hi,

Yes, you will need to re-add these modifications after the theme update.
This happens because you try to access the theme’s index.php file directly and this is caused by the theme’s inability to locate the WordPress get_header function as it does not passed trough WordPress when the request is made and in that case the function doesn’t “exist”.

Thanks!

Post count: 45

Hi Alin,
If i copy index.php to Newspaper-child folder, do you think i can do this trick here?.
Thanks.

Post count: 22421

Hello,
Unfortunately index.php will not work from the child theme. You have to use the main theme files.
Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.