• Resolved JacoboPolavieja

    (@jacobopolavieja)


    Hi all,

    I am creating a child theme and the child style.css works good. But when I copy the header.php file to the child theme in order to modify it, nothing is showed upon reload. Just a blank page and when I go through the HTML I see the <head> section of the page contains everything it should but then the <body> HTML is completely missing. Not one single line of code there.

    Why could this be happening? I’ve copied other files such as index.php and modified them without a problem. But the moment I put a header.php file there, this is what happens.

    Any help appreciated. Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Have you checked for any HTML mark-up errors?

    https://validator.w3.org/

    Thread Starter JacoboPolavieja

    (@jacobopolavieja)

    Hello WPyogi and thank you for helping,

    When I check without copying the file to my child theme, the validator displays 9 errors, but as I say, the page shows ok.

    When I take that same header.php from the parent theme and copy it to the child one, the pages doesn’t shows, and when trying to get it through the validator, it shows the error: “Sorry! This document cannot be checked. 500 Internal Server Error”.

    I am astonished, just from copying the original file to the child theme, and only with the header.php one… Might this be an issue with my server? If so, any idea what could be provoking this?

    Thank you very very much. Cheers!

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    What if, in your Child Theme header.php file, you replace all PHP (apart from top comments) with HTML.
    E.g;

    <?php
    /**
     * The Header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="main">
     *
     * @package Packagename
     * @subpackage subPackagename
     */
    ?>
    djsaijdsijaojdoisajdsoia

    Thread Starter JacoboPolavieja

    (@jacobopolavieja)

    Hi Andrew Nevins,

    The header.php has lots of PHP scripts, but letting just you example it works…

    This is really weird. Is there any reason why the same file works on a theme and not on a child one?

    Thank you for helping. Cheers!

    Thread Starter JacoboPolavieja

    (@jacobopolavieja)

    Hi again,

    After copying line by line the original header.php to the child’s one I managed to see what piece of code prevent it from working ok.

    As weird as it sounds, inside the header.php this theme has the following piece of php inside a <style> tag: https://pastebin.com/Q1rTnV1b

    When I remove just those lines, the rest works without problem. As to why it works on the master template but not here, even just copying the entire file, I just don’t know…

    Thank you for all the help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘No HTML in after adding header.php to child theme’ is closed to new replies.