Fatal error due to Newspaper Theme?

Posted in: Newspaper
Post count: 436

Hi,
So I was experiencing few fatar errors at some points while working on the backends ( like editing posts, exploring theme options)

Ofcourse, I thought it’s because my hosting server goes down or something related to that. So, I consulted my hosting people. They checled it extensively and replied this:

Our systems admin has concluded that this is not a host related issue, but it’s linked to your theme:
PHP Fatal error: Call to undefined function get_header() in /home/4XXX_ES/web/mydomain.com/private_home/wp-content/themes/Newspaper/index.php on line 6

Please look into this issue. It doesn’t happen always but somtimes.

Post count: 6535

Hi,

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 dose not passed trough WordPress when the request is made and in that case the function doesn’t “exist”.
You can read more about this and also have a solution for this here: http://ardamis.com/2011/06/02/fix-for-php-fatal-error-get_header-in-wordpress/

Thanks!

Post count: 436

Hi, I tried to understand the solution suggested by you, but unable to understand few things.

Why such a well coded theme like Newspaper is unable to locate get_header() function ? If it’s a known error why haven’t you tried to fix it permanently. I never noticed such issues in previous theme.

Should I concern about any thing which causes this error?

About the soultion implementation, my Index.php starts with

<?php
/* ----------------------------------------------------------------------------
the blog index template
*/

get_header();

//set the template id, used to get the template specific settings - this was the old home.php template
$template_id = 'home';

//prepare the loop variables
global $loop_module_id, $loop_sidebar_position;
$loop_module_id = td_util::get_option('tds_' . $template_id . '_page_layout', 15); //module 1 is default
$loop_sidebar_position = td_util::get_option('tds_' . $template_id . '_sidebar_pos'); //sidebar right is default (empty)

and it doesn’t have any define ‘display_errors’ as mentioned in the solution:

My question is in our themes index.php:

Where do we need to add the following code:


<?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;
}; ?>

Please help. Thank you.

Post count: 22421

Hi,

This issue happens when the index.php file is called directly. Something that would not normally happen when browsing a site, only found by crawlers which find all of the possible url’s in a site. Please follow these 2 links.

This topic should explain things better https://forum.tagdiv.com/topic/a-few-errors/
basically you need to replace the get_header code with the one Andrei pointed out.
But as a note…this is useless as the error is a false positive of sort. it will not affect anything except give you this information. Do this only if it bugs you. The theme has a custom header that is not grabbed from WP and the crawlers do not detect it as an existing function in the WP code. It’s not really a valid error. If something is not as the crawler likes it to be, it does not mean it’s not OK. A standard user will not have acess to this link at any time except if he manually types it in: /home/4XXX_ES/web/mydomain.com/private_home/wp-content/themes/Newspaper/index.php

Thank you!

Post count: 436

Hi Bogdan,
Thank you for the reply. Actually I am facing fatal errors like this as shown in the images below. It’s not just a error log, but it actually affects my work whenever it appears while working with editing posts or any other options.

Image link 1

Error Link 2

I am not sure if it’s the same issue whose solutions are discussed by you both above but when I asked for resolution to my hosting service provider, they come to the following conclusion after working on my issue. They said:

Our systems admin has concluded that this is not a host related issue, but it’s linked to your theme:
PHP Fatal error: Call to undefined function get_header() in /home/4XXX_ES/web/mydomain.com/private_home/wp-content/themes/Newspaper/index.php on line 6

I am confused about this issue as if to whom should I ask for solution. Can you relate your solution with the screenshot that I shared above?

Please help. Thank you.

Post count: 22421

Hi,

I cannot say for sure if the errors are related. It looks like a hosting error to me.
Did you increase your system status parameters according to our guide? https://forum.tagdiv.com/system-status-parameters-guide/ it could e a memory issue or it could be related to the get header but we have no reports of this yet. Just making assumptions. sorry.
Try the method me and Andrei posted above to make a redirect to the homnepage on the get_header code and see if you still get the errors.

Thanks

Post count: 436

Hi Bogdan,
I have already setup the get-header related soultion provided by your and Andrei. I haven’t expereinced nor been reported by any of my authors for any such new errors but even before, it used to appear only few times. Let’s see if gets solved.

and yes, based on https://forum.tagdiv.com/system-status-parameters-guide/ , my hosting system is 2 times more capable than the recommended requirment set written there. My memory limit set to 128MB by hosting provider based on my request and it’s google cloud based capable managed WP hosting service.

Do you think in any possible way the “get header” issue can cause “fatar error” too ? just asking.

I will keep you updated if I will get reported again about this.

Post count: 22421

Well we have no reports of the get_header issue causing fatal errors. if you do a search through this forum you will find quite a few topics regarding this issue but none reported fatal errors. In most cases there was only an error message in google’s structure data testing tool but nothing more. So I can;t say for sure your errors come from the get_header issue. You will have to wait and see if they come back even with the fix in place.

Thanks

Post count: 436

Yup!

Thank you 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
The forum ‘Newspaper’ is closed to new topics and replies.