Viewing 10 replies - 1 through 10 (of 10 total)
  • You’re seeing the following error most likely:

    Fatal error: Call to undefined function get_header() in [path]/index.php on line 7

    This is because the themes are not meant to be accessed directly. They are loaded by wordpress. What are you trying to accomplish? There may be another way to do it.

    [signature moderated Please read the Forum Rules]

    Thread Starter jason_333

    (@jason_333)

    You’re right jceresini, that is the error I see. I’m not trying to accomplish anything, I just don’t want the error because in Godaddy hosting one’s account username appears in the error path like so.

    Fatal error: Call to undefined function query_posts() in /home/content/a/b/c/USERNAME/html/wp-content/themes/theme_name/index.php on line 1

    This may not be that big of a security threat but it still does reveal one’s account username. So it would be nice if I could prevent this error message from showing and possibly all other error messages as well.

    I see. If you disable “display_errors” in your php.ini file this error message will be suppressed and that page should return a blank document

    Thread Starter jason_333

    (@jason_333)

    I was reading about the php.ini file this morning but unfortunately my economic hosting plan doesn’t allow me access to it. I was hoping there was some other way of suppressing errors but perhaps there isn’t ??

    Your host may not let you modify the php.ini file, but they should be willing to turn off “display errors” for you. Who do you host with?

    Thread Starter jason_333

    (@jason_333)

    Godaddy, right now I’m just on a economic plan until I finish building my site. I will soon be getting a dedicated server. I’m sure I will have control over the php.ini file then, if not I will ask them to turn off display errors for me. I saw some PHP snippets posted on the web that are supposed to prevent error messages but I could mever get them to work and I’m pretty sure it can’t be done with htaccess. So I’ll just have to do it the php.ini way I guess. Thanks.

    Actually, that won’t work. If they’re accessing the theme pages directly its not going to parse the wp-config.php. You can, however, place

    @ini_set('display_errors','Off');

    in each of your theme files. Thats a bit intrusive though

    Thread Starter jason_333

    (@jason_333)

    Wow this does actually work:

    <?php @ini_set('display_errors','Off'); ?>

    I wonder why it only works if I put it in template files and not when I just put it in header.php. After all, all my template files have a call to the header in them. Buy yeah, putting it in each file is a bit too much.

    Thread Starter jason_333

    (@jason_333)

    samboll thanks, I never knew errors could be suppressed using wp-config. I added the bit of code from the codex and it did suppress errors, not for directly accessed files but still very helpful.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Directly accessing theme folder shows fatal error’ is closed to new replies.