Title: Cannot modify header information error &#8211; functions.php
Last modified: August 20, 2016

---

# Cannot modify header information error – functions.php

 *  Resolved [carloravelli](https://wordpress.org/support/users/carloravelli/)
 * (@carloravelli)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/)
 * I am getting a cannot modify header information error on my functions.php, more
   specifically a file it’s including (which is not the issue).
 * `Warning: Cannot modify header information - headers already sent by (output 
   started at /home/yc/domains/yc.keytoe.nl/public_html/wp-content/themes/yourconnector/
   inc/metaboxes.php:6) in /home/yc/domains/yc.keytoe.nl/public_html/wp-includes/
   pluggable.php on line 881`
 * Metaboxes.php is my metabox file, where I have all my code for just that. Everything
   works fine except when trying to save anything, I get a blank page. The save 
   is succesful but I have to manually go back to wp-admin and that obviously isn’t
   how it’s supposed to work.
 * My metaboxes.php code is:
 *     ```
       <?
       // --- METABOX CREATE --- //
       add_action('admin_init', 'page_spec_meta');
   
       function page_spec_meta(){
       (this is line 6)	$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
        if ($template_file == 'talenten.php')
           {
       		add_meta_box("career-meta", "Career", "career_meta", "page", "normal", "high");
               add_meta_box("business-meta", "Business", "business_meta", "page", "normal", "high");
               add_meta_box("inspired-meta", "inspired", "inspired_meta", "page", "normal", "high");
               add_meta_box("network-meta", "Network", "network_meta", "page", "normal", "high");
               add_meta_box("future-meta", "Future", "future_meta", "page", "normal", "high");
           }
       	if ($template_file == 'bedrijven.php')
           {
       		add_meta_box("unique-meta", "Unique", "unique_meta", "page", "normal", "high");
               add_meta_box("providing-meta", "Providing", "providing_meta", "page", "normal", "high");
               add_meta_box("inspired-meta", "inspired", "inspired_meta", "page", "normal", "high");
               add_meta_box("network-meta", "Network", "network_meta", "page", "normal", "high");
               add_meta_box("future-meta", "Future", "future_meta", "page", "normal", "high");
           }
       }
   
       ....rest of the page
       ?>
       ```
   
 * I can’t really figure out what’s wrong. It can’t be whitespaces, checked all 
   that.

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/?output_format=md)
[1](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/?output_format=md)
2

 *  Thread Starter [carloravelli](https://wordpress.org/support/users/carloravelli/)
 * (@carloravelli)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/page/2/#post-3154560)
 * It differs per page. On the page where I save the metaboxes I only get that error,
   yes. On pages that don’t have the meta boxes I get errors telling me wordpress
   can’t find the meta boxes, but that’s logic.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/page/2/#post-3154561)
 * Try it with this metaboxes.php: [http://pastebin.com/gr7zVEkU](http://pastebin.com/gr7zVEkU)
 * Check if WP_DEBUG is set to true in your wp-config.php:
    [http://codex.wordpress.org/Debugging_in_WordPress](http://codex.wordpress.org/Debugging_in_WordPress)
 * If so, set it to false.
 *  Thread Starter [carloravelli](https://wordpress.org/support/users/carloravelli/)
 * (@carloravelli)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/page/2/#post-3154562)
 * Magic! Did it have to do with the admin_init?
    I’ve got to look through that 
   a couple of times to see what I did wrong.
 * Works perfectly, thanks a lot!
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/page/2/#post-3154563)
 * > Magic! Did it have to do with the admin_init
 * Your code produced a lot of Notices when WP_DEBUG was set to true, so I changed
   it to not produce any notices. When using the ‘save_post’ action hook you cannot
   produce errors or notices (or print or echo something out). If you do, you get
   the headers already sent by … in wp-includes/pluggable.php error. I changed the
   admin_init to load-post.php action hook so it only executes on already published
   posts.
 * I’m glad you got it solved.

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/?output_format=md)
[1](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/?output_format=md)
2

The topic ‘Cannot modify header information error – functions.php’ is closed to 
new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 19 replies
 * 5 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/cannot-modify-header-information-error-functionsphp/page/2/#post-3154563)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
