Hi, I am trying to code options page for a new wordpress theme. I followed following tutorial to code this page http://blog.themeforest.net/wordpress/create-an-options-page-for-your-wordpress-theme now the problem is i am getting Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\htdocs\wordpress\wp-content\themes\crunchtech\functions.php:195) in C:\xampplite\htdocs\wordpress\wp-content\themes\crunchtech\functions.php on line 47 Code (markup): here is the code function mytheme_add_admin() { global $themename, $shortname, $options; if ( $_GET['page'] == basename(__FILE__) ) { if ( 'save' == $_REQUEST['action'] ) { foreach ($options as $value) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } foreach ($options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } [B][COLOR="Red"]header("Location: themes.php?page=functions.php&saved=true");[/COLOR][/B] die; } else if( 'reset' == $_REQUEST['action'] ) { foreach ($options as $value) { delete_option( $value['id'] ); } [COLOR="Red"][B]header("Location: themes.php?page=functions.php&reset=true");[/B][/COLOR] die; } } add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin'); } Code (markup): i have colored conflicting lines. Please help me in fixing this issue. Thanks in advance.
The line you need to look at is: C:\xampplite\htdocs\wordpress\wp-content\themes\crunchtech\functions.php on line 47
Just except some CSS formatting problem, I can see no PHP error on the linked page. Anyway, you need to check line 195 not 47. I believe either some output is printed on this line, or cookie is set. Suppose you're printing from your php file using print, echo or die function, or you're setting a cookie. It means, the server already started sending http response to the client. On the way, you cannot modify the http header and redirect the user to different page. This is how a web server and a PHP scripts works.
You need to add this at the beginning of your PHP script: ob_start( ); PHP: And this at the end of your PHP script: ob_end_flush( ); PHP:
finally figured out the problem. It was basically xampp which was causing this problem as when i uploaded files to web server code was executing fine without throwing any errors. Thanks to all those who tried to help me
Never use XAMPP. I believe, some people here will protest my idea. But still I have to say, XAMPP is the worst Apache based web server I've ever used. Instead try Apache2Triad. It's not featureful, but it's perfect. I never became able to run hello_world.php file even, on this server.