WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Help! My Twenty Eleven Child theme won't let me save anything on server (7 posts)

  1. 5high
    Member
    Posted 1 year ago #

    HI,

    I've been developing a child theme for 2011 for a while now on my localhost/pc and all was looking good (have followed all the tuts in codex + forums etc). So did a fresh wp install in root of my current site and checked it with standard 2011 theme - all good.
    Then uploaded my child theme and activated it, but now can't save any changes to my pages, or even save other settings (could at first) and this warning is displayed for every page:

    Warning: Cannot modify header information - headers already sent by (output started at /home/trevorpe/public_html/wp-content/themes/twentyeleven_child/functions.php:8) in /home/trevorpe/public_html/wp-includes/pluggable.php on line 881

    The only code I have in my child functions at line 8 =

    <?php
    add_theme_support( 'custom-header' );
    ?>

    and the total code in it is only this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Twenty Eleven Child Theme functions and definitions</title>
    </head>
    <body>
    <?php
    add_theme_support( 'custom-header' );
    ?>
    </body>
    </html>

    which is what I thought it should be...

    Any ideas what this warning means and how I can fix it?? Otherwise I'm totally stuck!
    All help very gratefully received. Thanks.

  2. curtismchale
    Member
    Posted 1 year ago #

    The shouldn't be any of that HTML in your functions file.

  3. 5high
    Member
    Posted 1 year ago #

    Do you mean that literally all that should be written in my child theme functions.php file is this -

    <?php
    add_theme_support( 'custom-header' );
    ?>

    and nothing else at all in the header bit?? And that's what the 'Warning' message (as per my 1st post) was about??
    Cheers.

  4. 5high
    Member
    Posted 1 year ago #

    When I tried it first with just that line of php removed, it still didn't work, but have since got it working by totally removing my child functions.php file AND when I keep it in but had no php calls and no spare lines between the php marks - so all good now. I guess I'd either written it incorrectly, or was calling a function that the new 2011 theme does anyway - so was causing a conflict?
    Thanks for your help - but would appreciate your comments on this, Curtismchale, so I can learn for the future!
    Cheers.

  5. 5high
    Member
    Posted 1 year ago #

    Oops - well it appeared to be working...till I tried to sign out, the it displayed MULTIPLE warning errors (similar to before)...so have changed the child functions.php to just empty php tags - with nothing else at all in

    <?php
    ?>

    and it works again. So I guess that's what you meant by NO html in it!
    I feel a total idiot for doing this! Not sure where I got the header bit from now, as it was at the start of exploring how to do a child theme.
    So thanks for your help.

  6. curtismchale
    Member
    Posted 1 year ago #

    There should be no HTML in your functions.php file. If you have a closing PHP tag ?> you also need to make sure that there is no whitespace at all after it. No spaces no new lines.

    Really you don't need the closing PHP tag at all. The file could just be;

    <?php
    all your code
  7. 5high
    Member
    Posted 1 year ago #

    Thanks for the feedback Curtismchale - and your help of course. All good now and I'll probably just try to avoid using the functions.php unless I really have to, as it's a whole new code to me... or I'll have to try and learn it! My next new task maybe...
    Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic