0

When I include some div into a plugin I am creating I get an error when activating the plugin. "The plugin generated 33 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin."

Though the plugin works on the site but I get an error when activating it. here is the plugin code. I want it to display the text on top of the page. I understand I need to use some hooks, but which one? hre is a link showing what I want. http://wsoplugins.com/wp-content/uploads/2012/04/Captur.png

<?php
/*
Plugin Name: test
Plugin URI:
Description: test
Author: Ronny Kibet
Author URI: 
version: 1.0
*/

?>
<div id="bar">hello there</div>
5
  • Where exactly do you want to output this html? Or, what does your plugin exactly do? Commented Apr 28, 2012 at 12:52
  • I want the plugin to display the text on top of the page.
    – Ronny K
    Commented Apr 28, 2012 at 13:49
  • Top of the page? Where exactly? Can you make an image and point where you want the text to appear on your page? Commented Apr 28, 2012 at 13:52
  • here is a link showing what I want.wsoplugins.com/wp-content/uploads/2012/04/Captur.png
    – Ronny K
    Commented Apr 28, 2012 at 14:12
  • Check my answer... Commented Apr 28, 2012 at 14:38

1 Answer 1

1

The answer...

add_action('init', 'text_on_top');

function text_on_top(){
    ?>
        <div id="bar">hello there</div>
    <?
}

Never output anything outside of a function, use a suitable action/filter to do so!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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