WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer
thanks. I actually used Wp_head and it seemed to work. – Ronny Apr 29 '12 at 17:31
@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 posting your answer, you agree to the privacy policy and terms of service.

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