Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Setup a Bootstrap Theme Creating Bootstrap Navigation in WordPress

Error creating page in WP

Hi, I am following this video () and when I create a new page, I get this error from WordPress:

Warning: Cannot modify header information - headers already sent by (output started at ../../bootstrap-to-wp/wp-content/themes/bootstrap-to-wp/functions.php:44) in ../../bootstrap-to-wp/wp-admin/post.php on line 233

Warning: Cannot modify header information - headers already sent by (output started at../../bootstrap-to-wp/wp-content/themes/bootstrap-to-wp/functions.php:44) in ../../bootstrap-to-wp/wp-includes/pluggable.php on line 1178


line 233 on post.php:

// Session cookie flag that the post was saved
    if ( isset( $_COOKIE['wp-saving-post'] ) && $_COOKIE['wp-saving-post'] === $post_id . '-check' ) {
        setcookie( 'wp-saving-post', $post_id . '-saved', time() + DAY_IN_SECONDS );
    }

line 1178 on pluggable.php:

$location = wp_sanitize_redirect($location);

    if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
        status_header($status); // This causes problems on IIS and some FastCGI setups

    header("Location: $location", true, $status);

    return true;
}

...ΒΏDo you know why??

Thanks!

5 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

Check your wp-config.php and remove any spaces that are on newlines/line-breaks above and below the opening and closing php tags.

You may have to check any other php files you have edited.

I don't know what text editor you are using, but do NOT use Windows Notepad or Word for editing. However, if you are using Windows Notepad, always be sure that when doing 'Save As' you have encoding set to UTF-8 and not ANSI.

Hi, Sean it is happening again! When I create a new page, the browser takes me to a blank page ... (http://localhost/website/wp-admin/post.php)... then I have to change the url in the browser in order to get to WP admin area.

Any idea why is this happening?

Thanks!

Sean T. Unwin
Sean T. Unwin
28,690 Points

Set WP_DEBUG to true in your wp-config.php then reload that blank page and see if you get a message.

I get this:

Warning: Cannot modify header information - headers already sent by (output started at /../../website/wp-content/themes/bootstrap-to-wp/functions.php:46) in /../../website/wp-admin/post.php on line 233

Warning: Cannot modify header information - headers already sent by (output started at /../../website/wp-content/themes/bootstrap-to-wp/functions.php:46) in /../../website/wp-includes/pluggable.php on line 1178

This is the functions.php:

<?php

function theme_styles() {

    wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
    wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );

}
add_action( 'wp_enqueue_scripts', 'theme_styles' );

function theme_js() {

    global $wp_scripts;

    wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js', '', '', false );
    wp_register_script( 'respond_js', 'https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js', '', '', false );

    $wp_scripts->add_data( 'html5_shiv', 'conditional', 'lt IE 9' );
    $wp_scripts->add_data( 'respond_js', 'conditional', 'lt IE 9' );

    wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
    wp_enqueue_script( 'ie10viewport_js', get_template_directory_uri() . '/js/ie10-viewport-bug-workaround.js', array('jquery'), '', true );
//IE10 viewport hack for Surface/desktop Windows 8 bug 

}
add_action( 'wp_enqueue_scripts', 'theme_js' );

//add_filter( 'show_admin_bar', '__return_false' );

add_theme_support( 'menus' );

function register_theme_menus() {
    register_nav_menus(
        array(
            'header-menu'   => __( 'Header Menu' )
        )
    );
}
add_action( 'init', 'register_theme_menus' );


?>

Checking the funtions.php I found that I had nothing written on line 46!! It was empty. I deleted empty lines and itΒ΄s working now... Ghost lines??

Thanks for caring, Sean!

Sean T. Unwin
Sean T. Unwin
28,690 Points

My pleasure. Glad you got it sorted out. :)

Sean T. Unwin
Sean T. Unwin
28,690 Points

Have you checked in wp-config.php for whitespace before the opening php tag and after the closing php tag?

Have you entered in the keys and salts -

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');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

It happened creating a new page from the admin.

Yeah! it happened because of whitespace after the closing php tag, on the funtions.php file.

Now lines are deleted and working. Thanks!!!!