WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Twelve error_log.php shows Call to undefined function get_header() (2 posts)

  1. 5high
    Member
    Posted 4 months ago #

    Hi,

    I'm checking through my twenty twelve child theme (via Theme Check plugin - as part of tightening the security of my WP site) and it showed this:

    WARNING: error_log PHP error log found.

    ... so I tracked down all my error-log.php files to see what was in them, before i considered deleting them (though still unsure if this is a wise move?)!

    In my .../wp-content/themes/twentytwelve/error-log.php I found 2 references of "PHP Fatal error: Call to undefined function get_header()" in 2 files:
    1. /wp-content/themes/twentytwelve/404.php on line 10
    2. /wp-content/themes/twentytwelve/index.php on line 17

    But when I look at these reported errors, the code looks fine to me, and they are the standard WP Twenty Twelve files, so show this for # 1:

    <?php
    /**
     * The template for displaying 404 pages (Not Found)
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>

    and this for file # 2:

    <?php
    /**
     * The main template file
     *
     * This is the most generic template file in a WordPress theme
     * and one of the two required files for a theme (the other being style.css).
     * It is used to display a page when nothing more specific matches a query.
     * For example, it puts together the home page when no home.php file exists.
     *
     * @link http://codex.wordpress.org/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>

    I've read through heaps of threads here, and as it's not an issue with my theme header or index file being in the root, or of any edits in my header or 404 files, I'm not sure what to do? Or as my site seems to be working, maybe I should just ignore it??

    There was one post/tutorial for a fix for this (see http://ardamis.com/2011/06/02/fix-for-php-fatal-error-get_header-in-wordpress/) though it seems a bit odd to have to do this for a standard WP theme. Any thoughts anyone?

    The only thing I can think of is to add in some extra php tags, so it mimics the WP codex in the 'Function Reference/get header' so it's like this:

    <?php /* Your Commment Here */ ?>
    <?php get_header(); ?>

    but as I understand that's the same..?

    Any comments or advice much appreciated. Thanks.

  2. 5high
    Member
    Posted 4 months ago #

    OK, after loads more reading around this, I think it (the code in the 2012 Theme index and 404 php files) all looks good and was possibly related to a 2012 Theme issue which has since been fixed, as the 2 error logs were 2 and 6 weeks ago??? So will ignore for now!

Reply

You must log in to post.

About this Topic