I get this error when I change theme in my wordpress. *Cannot modify header information - headers already sent by (output started at /home/mortgage/public_html/autoblogdemon.com/test/wp-content/plugins/test/test.php:28) in /home/mortgage/public_html/autoblogdemon.com/test/wp-includes/pluggable.php on line 866*

Notice output started ar test.php:28

here is test.php and line 28 is the second opening

Plugin Name: test
Plugin URI: 
Description: is about to leave the page. make sure you check out the demo of the plugin.
Author: Ronny Kibet
Author URI: 
version: 1.0

//html begins here.
function my_text_on_top(){


<!-- bar starts here -->
<div id="bar">hi there </div>

<?php // line 28 starts here.


the plugin works fine by showing a "hi there" text inside of the div with id "bar".

can somone help me get rid of the error and be able to change my themes when I activate the plugin.



The issue is that your plugin should not be outputting anything to the browser on init. As you can see by the error, some code in pluggable.php is trying to set a header, but headers were already sent when your plugin sent output. If you want to output markup, you have to hook something in the page body, like wp_footer.

  • @Ronny - wp_head is fired before the opening body tag, so outputting markup there may have unpredictable results depending on the browser. – Milo Apr 29 '12 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.