Cannot modify header? (10 posts)

  1. lilqhgal
    Posted 6 years ago #

    I have a custom theme installed. I have user registration turned ON and allow users to add posts. Everything worked fine up until sometime yesterday (as that is the date of the most recent post). All of a sudden I'm getting the "Cannot modify header" error. I haven't changed anything in weeks and everything has worked until now. At first, the error was referencing all-in-one-seo-pack/aioseop.class.php:221 and wp-includes/pluggable.php on line 868 ... so I just flat out disabled the all-in-one-seo plugin. The error was still there but then changed to my theme header.php file line 4, so I checked that for extra spaces which it has none. Line 4 was my <meta> stuff, so I just deleted that, and the error still persists (now line 5). I disabled *ALL* plugins (everything, completely) and the error was still there. I am at a loss as the normal methods of fixing this (extra spaces, etc.) aren't fixing it. Any ideas are GREATLY appreciated!!!!

  2. Roy
    Posted 6 years ago #

    Just as an option 10, but the error also occurs when you have spaces or linebreaks in the wp-config file.

  3. Shane G.
    Posted 6 years ago #


    It is usually due to spaces, new lines, or other garbage at opening/closing PHP file <?php tag or after a closing ?> tag in wp-config.php. It can be other file too so need to check error message as it may list file name where the error occurred.

    You can either upload error file from the backup or edit erroneous file. To edit the file one need to check below mentioned points:

    1. Download the file mentioned in the error message.

    2. Open that file in a plain text editor

    3. Check that the very first characters are <?php

    4. Check that the very last characters are ?>

    5. Place the cursor between the ? and >

    6. Now press the DELETE key on your computer and keep that key pressed for at least 15 seconds.

    7. Now type > and

    8. Save without pressing any other key at all.

    That’s it!


    Shane G.

  4. lilqhgal
    Posted 6 years ago #

    Spaces? How can you not have spaces? And I don't understand why it would've worked for a few weeks just fine and then BAM crap out. Here is my wp-config file (with pertinent info removed):

     * The base configurations of the WordPress.
     * This file has the following configurations: MySQL settings, Table Prefix,
     * Secret Keys, WordPress Language, and ABSPATH. You can find more information by
     * visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
     * wp-config.php} Codex page. You can get the MySQL settings from your web host.
     * This file is used by the wp-config.php creation script during the
     * installation. You don't have to use the web site, you can just copy this file
     * to "wp-config.php" and fill in the values.
     * @package WordPress
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'mydbname');
    /** MySQL database username */
    define('DB_USER', 'mydbusername');
    /** MySQL database password */
    define('DB_PASSWORD', 'mydbpasswd');
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
     * Authentication Unique Keys.
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     * @since 2.6.0
    define('AUTH_KEY', 'put your unique phrase here');
    define('SECURE_AUTH_KEY', 'put your unique phrase here');
    define('LOGGED_IN_KEY', 'put your unique phrase here');
    define('NONCE_KEY', 'put your unique phrase here');
     * WordPress Database Table prefix.
     * You can have multiple installations in one database if you give each a unique
     * prefix. Only numbers, letters, and underscores please!
    $table_prefix  = 'wp_';
     * WordPress Localized Language, defaults to English.
     * Change this to localize WordPress.  A corresponding MO file for the chosen
     * language must be installed to wp-content/languages. For example, install
     * de.mo to wp-content/languages and set WPLANG to 'de' to enable German
     * language support.
    define ('WPLANG', '');
    /* That's all, stop editing! Happy blogging. */
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');

    See anything obvious?

  5. lilqhgal
    Posted 6 years ago #

    What I don't understand also, is I started looking around on some of my other wordpress installs and I found several wp-config files that *HAD* the extra space at the bottom of the ?> and the sites worked fine.

  6. lilqhgal
    Posted 6 years ago #

    Not sure why my wp-settings file doesn't have an end ?> but I added one and uploaded and still have problems.

  7. Roy
    Posted 6 years ago #

    A reference to the docs:

    If all fails, it's always an option to reupload the WP files. Maybe some plugin somehow edited some core file, it's hard to say at this point. I'd start with making a new WP-config file, not edit the old one. Just get one from a WP download, edit it and reupload it. If that doesn't work, perhaps the plugin even though disabled might still cause problems, so delete the SEO pack. Then if still necessary reupload the entire includes folder. If still necessary the other WP files as if upgrading manually. The original theme files. Etc.

    But maybe somebody has a better option.

  8. lilqhgal
    Posted 6 years ago #

    Thanks Gangleri,

    Yeah I ready that link already which is why I'm so confused. I suppose I will have to go through and edit all the files. I'm seeing if my host has a recent backup that's close enough to not lose a bunch of data, but far back enough that will let me get back to when the site was working. If not I will do the one by one steps above.

    Still doesn't explain the mystery on why something works fine one day and craps out the next? *scratching head*

  9. Roy
    Posted 6 years ago #

    I wouldn't go changing files, nor replacing backups. You can delete all WP files and all your posts, comments, etc. will still be in the database. I'd replace the files that could cause this with files that I am certain are not flawed, i.e. from fresh downloads.

    How it happend? Accidentally, a plugin did something, a h...

  10. lilqhgal
    Posted 6 years ago #

    Well I figured it out (I think... so far it seems to be the culprit.)

    My custom theme had several files (index, single, category, etc) that require the use of another file, so I had it called in each of the files by using the following:

    require_once dirname( __FILE__ ) . '/form_process.php';
    get_header( );
    include_my_custom_form( );

    I modified the file to put most of that into the header.php file, and then just used the regular <?php get_header(); ?> call. For whatever reason, that breaks the site and throws the header errors. I can now use the site with all the plugins still running smooth and not getting these issues. What I DON'T understand, however, is I had made these changes before releasing the website to the public, and have received numerous posts (30+) without any issues. Then after 2+ weeks of the site being live, all of a sudden it doesn't work.

Topic Closed

This topic has been closed to new replies.

About this Topic