WordPress.org

Ready to get started?Download WordPress

Forums

Header.php in a Twenty Ten Child Theme (10 posts)

  1. montygothic
    Member
    Posted 3 years ago #

    Hi,

    Why do I encounter a blank white page that includes only text (as if there is no CSS file) when you add a Header.php file to a Child Theme of Twenty Ten?

    My Child Theme example is basic:

    Style.CSS
    Functions.php
    Footer.php (includes <?php wp_footer();?>)

    And it works fine, it does what I need into do. But when I add the following Header.php, which I add as most plugins need <?php wp_head();?>

    The site looses all Style and becomes a white page with only text.

    Can someone tell me why I encounter this behaviour after adding a Header.php file with only the following code<?php wp_head();?>

    Many Thanks

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    because you are missing all the important items from the header.

    You need all the stuff in header.php, from the first line, to the </head> tag

    Or at least most of it......
    it tells the browser your doctype. html profile, calls in your css, etc

  3. montygothic
    Member
    Posted 3 years ago #

    I see,

    So just to check, I can have a footer.php file containing just <?php wp_footer();?>
    and it's good to go or is there also necessary code missing?

    My intentions are just based on using a child theme but making sure wp_footer & wp_head are included.

    At the same time I know that the required blank functions.php with <?php?> pulls all the functions through.

    I notice some plugins are affected when I use just the functions.php file; for example, to fix problems like an animated calender pop up not showing I must add a footer.php file with <?php wp_footer();?> anf hey presto it's fixed.

  4. Jam
    Member
    Posted 2 years ago #

    I have a similar question, I am new to child themes.

    If I want to edit header.php, I create a header.php (with nothing in it) in the child theme, but everything goes blank.

    Do I need to copy all of the code from the parent to the child?

  5. montygothic
    Member
    Posted 2 years ago #

    Hi PiManIII

    Read this page it explains all you need to know

    http://codex.wordpress.org/Child_Themes

    The blank child header function loads in addition to the parent functions. If I need to add a Header.php file to the child theme; I ensure that it is customized and different to the parent. This will allow you to upgrade the parent theme without loosing any customizations.

  6. Ray Doniel
    Member
    Posted 2 years ago #

    Hi guys,
    what I've done was to copy the whole header.php to the heade.php of the child theme and then added the scripts I needed.
    It works great, do you think this is the best way to do this?

    thanks

  7. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    @Ray, that is exactly how it's done.

    Any file placed in the child theme loads in place of the parent theme.

    So if you put a header.php in your child theme, it is used, and the parent is ignored

    Same thing for index.php, page.php, etc.

    (style.css and functions.php are exceptions to this rule)

  8. Jam
    Member
    Posted 2 years ago #

    Then how do updates to WP take effect in a Child theme if you are using a Child Theme of say, TwentyTen? Won't the child theme simply override any updates?

    Thanks in advance!

  9. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    THat is correct.... the problem with a child theme is that you may not benefit from a theme update.

    But the point of the child theme is that you can make edits through the child theme safely.

    So you balance the pros and cons. I personally always redo the header.php in the above manner as I tend to heavily customize my site headers

    I'm using twentyeleven as my parent theme, so when an update comes through, I do a comparison of the update to see what has changed. It's not hard to look at the changelog and see what has changed. If anything were to have changed which is important, I would include the change on my child theme.

    That doesn't happen often, I've never needed to edit any of my child theme files for such a reason.

  10. Jam
    Member
    Posted 2 years ago #

    Awesome! Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic