简体   繁体   中英

Warning: Cannot modify header information - Wordpress

I did some research to solve this problem, but seems like not working for me, I have checked all the spacing, replaced original functions.php, double check wp-config.php but still not working for me. Im using wordpress 5.4 version, after I installed Elementor Pro and insert WP-Filebase shortcode, the error message showing up.

Warning: Cannot modify header information - headers already sent by (output started at /home/customer/www/xxx.xxx/public_html/xxx/wp-includes/class.wp-scripts.php:405) in /home/customer/www/xxx.xxx/public_html/xxx/wp-admin/admin-header.php on line 9>

Here is the class.wp-scripts.php on line 405

* Filters the HTML script tag of an enqueued script.
*
* @since 4.1.0
*
* @param string $tag    The `<script>` tag for the enqueued script.
* @param string $handle The script's registered handle.
* @param string $src    The script's source URL.
*/
$tag = apply_filters( 'script_loader_tag', $tag, $handle, $src );

if ( $this->do_concat ) {
        $this->print_html .= $tag;
    } else {
        echo $tag;
    }

    return true;
}

Here is the admin-header.php on line 9

header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
if ( ! defined( 'WP_ADMIN' ) ) {
    require_once __DIR__ . '/admin.php';
}

Dirty cheap solution, add @ in the header section.

@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM