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!
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

Kwame Gyau
Courses Plus Student 402 PointsWordPress Error After A Localhost Migration To Live Server - Please help.
The following is the error I'm getting after uploading files to a live server:
Warning: Cannot modify header information - headers already sent by (output started at C:\inetpub\vhosts\httpdocs\wp-content\themes\newstar\functions.php:1) in C:\inetpub\vhosts\httpdocs\wp-includes\pluggable.php on line 896
9 Answers
Andrew McCormick
17,730 Pointsthe most common reason for this that I've seen is extra white space in your php file. check you functions.php file for an extra line before your opening <?php
tag or after your closing tag.

Kwame Gyau
Courses Plus Student 402 PointsI have checked but no luck, Andrew - the problem still exist
Andrew McCormick
17,730 PointsDo you mind posting your functions.php file?
Andrew McCormick
17,730 PointsNext would be to try ob_start();
after your opening php tag in your functions.php file add ob_start();
and then at the end you need to close it, so before your closing php tag add ob_end_flush();
other things to try:
can you access your admin area?
You may just be missing a file, try to reupload your files to your live server
if you are not using the default theme can you switch to it, or delete your other theme folders if you cannot access the admin area
this is almost always caused by one small error or missing item.

Kwame Gyau
Courses Plus Student 402 PointsMany thanks for your time, Anthony.
The irony of the situation is there's not much in my functions.php file - please see below. I have included the ob_start() and ob_end_flush() functions as you suggested but the problem still persists.
<?php
ob_start();
//Enable custom Menus
add_theme_support('menus');
//Widget creation function
function make_widget($name, $id, $description){
$args = array(
'name' => __($name),
'id' => $id,
'description' => $description,
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h5>',
'after_title' => '</h5>'
);
register_sidebar($args);
}
make_widget('Search Widget', 'search_widget', 'This is a search widget');
make_widget('LeftPaneTop Widget', 'leftpane_top_widget', 'This widget appears on the top left side');
make_widget('LeftPaneBottom Widget', 'leftpane_bottom_widget', 'This widget appears below the top left side');
function my_search_form($text) {
$text = str_replace('value="Search"', 'value=""', $text);
return $text;
}
add_filter('get_search_form', 'my_search_form');
ob_end_flush();
?>
I look forward to hearing from you soon.
Andrew McCormick
17,730 Pointshmm.. did you try any of the other steps from above? other things to try:
-can you access your admin area?
-You may just be missing a file, try to reupload your files to your live server
-if you are not using the default theme can you switch to it, or delete your other theme folders if you cannot access the admin area

Kwame Gyau
Courses Plus Student 402 PointsApologies for addressing you wrongly, Andrew. Anthony? How did I come about that? LOL
Well, the issue is the homepage of the site loads okay but the links to other pages are broken so I need to access the admin area to search and replace these links which are still using 'localhost/'. So trying to access the admin area is what is giving the error:
Warning: Cannot modify header information - headers already sent by (output started at C:\inetpub\vhosts\httpdocs\wp-content\themes\newstar\functions.php:1) in C:\inetpub\vhosts\httpdocs\wp-includes\pluggable.php on line 896
Andrew McCormick
17,730 PointsKwanme, yes. It looks like you have some major issues with the migration. I just tried to login to the backend of your site and it's looking for localhost.
Did you do the correct search and replace on your database before importing it to your live database?
Make sure to read the Codex on Moving Wordpress especially where it says "When Your Domain Name or URLs Change"
You can use this tool to search and replace: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Or, I use WP Migrate DB. With this tool, you go ahead an install Wordpress on your live server, copy your wp-content. Install the Migrate DB plugin on both sites. Then tell Migrate DB to push from the local to the remote. It's super easy and I've had almost zero issues with it. Only issues I've seen where with some whacked out security plugins, but most of those issues are fixed in new versions.

Kwame Gyau
Courses Plus Student 402 PointsAndrew, I have ended up developing on the live server since all efforts to get to the bottom of the issue have proved futile.
Once again, many thanks for your help.

Kwame Gyau
Courses Plus Student 402 PointsMany thanks Andrew. I'll keep you posted with the outcome pretty soon. Give me some few hours.

Kwame Gyau
Courses Plus Student 402 PointsAndrew, I have ended up developing on the live server since all efforts to get to the bottom of the issue have proved futile.
Many thanks for your help anyway.