WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Warning: Cannot modify header information (13 posts)

  1. jabbo126
    Member
    Posted 1 year ago #

    Hi, i have different problem now. I don't know what it causes, but everytime when i edit my posts and for example change the category and then click "Update" i got this message:

    Warning: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/22236/virtual/www/subdom/wp-test-2/wp-content/themes/wp-test-2/functions.php:1) in /data/web/virtuals/22236/virtual/www/subdom/wp-test-2/wp-includes/pluggable.php on line 876

    When i go back to previos page the changes are ok, category have changed and it works fine. But i don't want this message :-).

    I've looked to pluggable.php on line 876, where is:

    header("Location: $location", true, $status);

    and i don't see anything wrong in it.

    Some other informations:
    - I'm making my own template from scratch
    - I don't use any plug-in right now (except Akismet, Hello Dolly and Meta Slider - but i tried to deactivate it - nothing changes)
    - I also look at my functions.php - i have no blank rows or spaces befor or after my <?php ?>
    - It must be something in my custom teplate, becouse when i change template, it works fine
    - I even try to empty my functions.php file and it still don't work, even if i have nothing at line 1
    - But it have to do something with functions.php, becouse when i delete it completly from my template directory, update button works fine without warning!

    This is what i have in my functions.php:

    <?php
    
    // functions
    
    if ( function_exists('register_sidebar') ) {
    
       register_sidebar(array(
       'name' => 'sidebar 1',
       'before_widget' => '<div id="%1$s" class="widget %2$s">',
       'after_widget' => '</div>',
       'before_title' => '<h2>',
       'after_title' => '</h2>'
        ));
    
       register_sidebar(array(
       'name' => 'sidebar 2',
       'before_widget' => '<div id="%1$s" class="widget %2$s">',
       'after_widget' => '</div>',
       'before_title' => '<h2>',
       'after_title' => '</h2>'
       ));
    
       register_sidebar(array(
       'name' => 'sidebar-right',
       'before_widget' => '<div id="%1$s" class="widget %2$s">',
       'after_widget' => '</div>',
       'before_title' => '<h2>',
       'after_title' => '</h2>'
       ));}

    But i think it is not important - just existence of functions.php causes it - even if i have empty functions.php file in template directory. When i get rid of it, everything works fine. But i need that file, of course :-)

    It is not criticall, becouse everything works fine, post is updated, but i have still this message.

    Thanx for help and sorry for my bad english :-)

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    The issue is in your theme's functions.php file. Try reviewing Solving "headers already sent" warnings.

  3. jabbo126
    Member
    Posted 1 year ago #

    esmi, thanx, but did you read everything I wrote?? there are NO spaces in my function.php. I even try to empty it completly with nothing in it. Still same issue.

    I already tried to delete all my WP files except my theme and upload new one - it didn't solve the problem.

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    did you read everything I wrote?

    Yes. Did you read the page at the link I posted above?

  5. jabbo126
    Member
    Posted 1 year ago #

    How can i have empty spaces in document, where is nothing? Becouse i tried to empty the file completly and it still does it. Yes, i did - i read it before you post it. I thing i've tried every common advice on this topic. I tried finde empty spaces, i tried unistall plugins, i tried empty functions.php, i tried upload new fresh WP files... nothing helps. Only if i change my template or get rid of functions.php the Warning stops comming.

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    Just because you cannot see anything does not mean that PHP sees the same.

    From Solving "headers already sent" warnings

    As I said, you need to actually read that page.

  7. jabbo126
    Member
    Posted 1 year ago #

    I've done it the way that is describe there. In my function.php and in my pluggable.php.

    1.Place the cursor between the ? and >
    2.Now press the DELETE key on your computer
    Note to MAC users: The "DELETE" key on a PC deletes characters to the right of the cursor. That is the key noted here.
    3.Keep that key pressed
    For at least 15 seconds
    4.Now type > and
    5.save without pressing any other key at all.
    6.If you press another key, you will bring the problem back.
    DO NOT PUT CODE IN UNNECESSARY CODE BLOCKS, PUT THEM IN A SINGLE PHP BLOCK.

  8. jabbo126
    Member
    Posted 1 year ago #

    As I said - i actually read that page and i actually do everything it says ...

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    Then there is nothing else we can do to help. The issue is clearly in your theme's functions.php file and this was confirmed when you removed that file.

  10. esmi
    Forum Moderator
    Posted 1 year ago #

    And do not touch any WordPress core files. The issue is NOT in pluggable.php as the error message clearly demonstrates

  11. jabbo126
    Member
    Posted 1 year ago #

    But i don't think that is it - becouse even if i upload function.php from default template in to it it do the same Warning message. But if i change templat to default, it works. So... i really don't know.

  12. jabbo126
    Member
    Posted 1 year ago #

    Thanx anyway ...

  13. jabbo126
    Member
    Posted 1 year ago #

    I've solved it. I don't know how, but really ther MUST be some spaces, even if i deleting like mad, hold del.(at end) and backspace(at front) for abou 30 seconds and then Save as without keyboard. Nothing helps. Then i just upload different functions.php from one tutorial i was making and voala ... it works. So i just copy/pase my functions without <?php ?> - and put it into tahat working file. Suddenly it works. I still don't understand it completly, becouse i've tried to upload different functions.php from another theme and it doesn't work. Now it is. Im glad, but still little bit nervous about this issue. Is really wierd...

Topic Closed

This topic has been closed to new replies.

About this Topic