Headers already sent error

I have a client that is getting error only when trying to preview a page she is editing.
This is the error:

Warning: Invalid argument supplied for foreach() in /home2/nexusipa/public_html/seminars/wp-content/themes/themo/inc/theme_init.php on line 702

Warning: Cannot modify header information - headers already sent by (output started at /home2/nexusipa/public_html/seminars/wp-content/themes/themo/inc/theme_init.php:702) in /home2/nexusipa/public_html/seminars/wp-includes/pluggable.php on line 1179

However, I can't seem to duplicate the issue with chrome, firefox or IE. Its a brand new install of Wordpress. Is this something I should take to the theme developer? Just thought maybe you guys might know a potential cause or maybe its just that persons computer since I can't duplicate.
Any suggestions :slight_smile: ?
Thanks!!!

  • George

    Do think it is possible that the issue could display for one person and not another with maybe a different browser? I tried on a couple computers and cannot reproduce the issue, I figured the empty space problem usually would trigger that error for everyone. That is a new theme though and I will check those files for empty spaces.

    If I want to try the output buffering they mentioned, where would I put the code for that?
    The instructions said to add to the script? This is only an issue when editing then previewing a page.
    thanks!

  • Ash

    Hello George

    Warning: Invalid argument supplied for foreach() in /home2/nexusipa/public_html/seminars/wp-content/themes/themo/inc/theme_init.php on line 702

    This is not an empty space error. If you go to /wp-content/themes/themo/inc/theme_init.php on line 702 you will see something similar to the following:

    foreach( $data as $key => $val )

    In the above example, $data is considered an array type variable. If the $data is not an array type variable, then you would see the above error.

    You can fix it adding a line before the foreach statement:

    $data = ! is_array( $data ) ? array() : $data;
    foreach( $data as $key => $val )

    or even just this:

    foreach( (array) $data as $key => $val )

    This way we make sure that $data is always an array, so you won't see any error.

    Note:
    1. The variable names are different in your theme code, I just gave a similar code
    2. You still need to contact theme developer, as when you will update the theme your changes will be lost.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.