Title: Weird wp_enqueue_script and Cannot modify header information Errors on Live site
Last modified: August 20, 2016

---

# Weird wp_enqueue_script and Cannot modify header information Errors on Live site

 *  [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/)
 * Hi,
 * I’ve recently moved to set up a live test site for my project and for whatever
   reason I’m getting errors that don’t appear on the local version (XAMPP powered
   of course).
 * Considering the site is still in dev I’ve never turned off WP_DEBUG so I know
   it’s always been working. I had to modify the memory to 64M to get it to load,
   but apparently that’s not uncommon.
 * I had a couple of “Cannot modify header information” errors which were white 
   space after the ?> related issues but when I go to login it’ll let me enter a
   username and password then when I press enter it dies and throws out this:
 *     ```
       Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php on line 2758
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-login.php on line 349
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-login.php on line 361
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 697
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 698
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 699
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 700
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 701
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 702
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 705
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 706
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 707
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 708
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 711
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 712
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 713
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 714
   
       Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 881
       ```
   
 * The only way I’ve found to get the live site to load and is to comment out the
   content of the _doing_it_wrong function between lines 2751 and 2759 of the wp-
   includes\functions.php file.
 * I have no idea why this should be on the live site and not the local!
 * Can anyone help please, I’ve been over all the posts and documentation I can 
   find with no answer.

Viewing 13 replies - 1 through 13 (of 13 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177026)
 * > Notice: wp_enqueue_script was called incorrectly. Scripts and styles should
   > not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts,
   > or init hooks.
 * That sounds like you’re enqueueing your scripts using the wrong hook. Have you
   reviewed [http://codex.wordpress.org/Function_Reference/wp_enqueue_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script)
 *  Thread Starter [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177030)
 * I’ve been over it and over it bud and I cannot see anything wrong. Also as I 
   said it works perfectly on local.
 * The functions file it mentions is the wordpress one so I haven’t touched it. 
   The only place I’ve enqueued a script in my whole theme is in my functions file
   and it looks like this:
 *     ```
       add_filter('wp_enqueue_scripts', 'remove_datepicker' );
       function remove_datepicker() {
       wp_dequeue_style( 'date-picker-style' );
       }
       ```
   
 * I appreciate the help here 🙂
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177037)
 * add_filter??? You should be using add_action. eg:
 *     ```
       if( !function_exists( 'emporium_enqueue_slider' ) ) :
       function emporium_enqueue_slider() {
            if( !is_front_page() ) return;
       	wp_register_script( 'emporium-eslider' , get_template_directory_uri() . '/library/ebxslider.js', array('jquery'),
           '1.3.2', true );
            wp_enqueue_script('emporium-eslider');
   
       	wp_register_script( 'emporium-eslider-config' , get_template_directory_uri() . '/library/ebxslider-config.js', array('jquery'),
           '1.3.2', true );
            wp_enqueue_script('emporium-eslider-config');
       }
       endif;
       add_action('template_redirect', 'emporium_enqueue_slider');
       ```
   
 *  Thread Starter [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177044)
 * Ok, I changed that but in all fairness I got that code snippet from a plugin 
   dev and I’ve never really got my head around the difference between add_filter
   and add_action as a lot of sources say they’re basically interchangeable.
 * As for the main issue, this changed nothing but I think there may be a wider 
   issue here as whenever I try loading a page that isn’t the home page or anything
   in the dashboard via the live site it jumps to the hosts 404 page, even using
   the preview page button from the dashboard, and because I couldn’t get past login
   this is the first time I’m seeing this error. So whether that’s related or not
   I don’t know but WordPress migration seems to be over complicated to me at the
   moment.
 * All I’ve done is load the database up then copy the files and redirect the settings
   from the dashboard, that should be enough surely? Oh my permalink structure works
   because on the dashboard page’s page it shows the slug correctly.
 * Am I being dense here and not understanding something?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177046)
 * > a lot of sources say they’re basically interchangeable.
 * Noo! They are completely different. Filters are the hooks that WordPress launches
   to modify text of various types before adding it to the database or sending it
   to the browser screen. Actions are triggered by specific events that take place
   in WordPress, such as publishing a post, changing themes, or displaying a page
   of the admin panel.
 *  Thread Starter [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177048)
 * Fair enough, that actually makes sense lol. As far as I can tell I’ve got them
   right throughout by copying examples so I won’t worry too much but I will definitely
   bare that in mind in future.
 * Now, as for the rest of this mess I’m at a loss as to what’s wrong with my uploaded
   site sadly.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177052)
 * Are you still getting the same errors in your debug log?
 *  Thread Starter [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177055)
 * Yeah, nothing different but only on login / out apart from that it appears normal(
   obviously ignoring the fact that no pages will load, but I think it’s related
   somehow).
 * It all seems to link back to how something is calling the _doing_it_wrong function
   on line 2758, but I don’t see how.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177084)
 * No – the line 2758 mention is a red herring. Something in your theme or a plugin
   is the actual cause of the problem. What happens if you switch to Twenty Eleven?
 *  Thread Starter [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177088)
 * No change upon using TwentyEleven bud. Just out of interest, do you know a simpler,
   free method of migrating a site? Might be worth a try in case something hasn’t
   gone right in that way perhaps?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177124)
 * You should have a look at [Moving_WordPress](http://codex.wordpress.org/Moving_WordPress).
 *  Thread Starter [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177127)
 * I’m sure I’ve followed everything outlined in there. But I’ll rebuild to uploaded
   site this afternoon and report back.
 * Cheers bud
 *  Thread Starter [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * (@theslink2000)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177191)
 * Ok, I’ve put the live site elsewhere and I’ve figured out what was causing this
   error, just not why.
 * The plugin [WP Custom Login](http://wordpress.org/extend/plugins/wp-custom-login/)
   was to blame. Deactivating this caused the error to vanish and it also explains
   why it only happened on login/out.
 * I’ve no idea why it does this on live servers and not localhost though…
 * If anyone has any insights they’d be most welcome, if not I’ll just have to work
   around using this plugin.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Weird wp_enqueue_script and Cannot modify header information Errors on
Live site’ is closed to new replies.

## Tags

 * [Cannot modify header information](https://wordpress.org/support/topic-tag/cannot-modify-header-information/)
 * [live site](https://wordpress.org/support/topic-tag/live-site/)
 * [wp_enqueue_script](https://wordpress.org/support/topic-tag/wp_enqueue_script/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 13 replies
 * 2 participants
 * Last reply from: [theslink2000](https://wordpress.org/support/users/theslink2000/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/weird-wp_enqueue_script-and-cannot-modify-header-information-errors-on-live-site/#post-3177191)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
