I am learning Wordpress from a book and while learning about how to use action hooks the author gives the below code . I am assuming this would change the footer at the front end .

function boj_example_footer_message() {
echo 'This site is built using < a href="http://wordpress.org"
title=”WordPress publishing platform” > WordPress < /a > .';
add_action( 'wp_footer', 'boj_example_footer_message', 100 );


To test this out I created a plugin and had the above code put in the main plugin file . However , upon activation I get

"The plugin generated 8 characters of unexpected output during activation. "

What causes this ? What is the correct way to echo to the front end on an action hook ? How to make this work ?

  • This can be caused by a few things. Typically, the cause is whitespace before or after the PHP tags. A good habit is to not use the optional closing PHP tag ?>. Check the answers to this question: stackoverflow.com/questions/4074477/… – jdm2112 Sep 5 '19 at 15:33
  • Thanks the error on activation went away upon removing the closing PHP tag . but still it doesnt change the footer . May be I am missing something – Knownow Sep 5 '19 at 16:09
  • 1
    There could be another problem with the way your plugin is setup. When I copy your function and action hook to a test site (in the functions.php file), the echo statement is firing fine. – jdm2112 Sep 5 '19 at 16:32
  • 1
    I just tried it in several plugins including Hello Dolly too and it works for me. I concur with @jdm2112 that there must be some other problem with your plugin. – Ted Stresen-Reuter Sep 5 '19 at 17:10
  • 1
    Sorry for the trouble people and thanks for all your help . I am unsure how things work in the front end in WP but found the echo from the hook in the source code at the front end . May be the theme doesnt show it . I will surely looking into debugging and error logs . – Knownow Sep 5 '19 at 18:34

Your Answer

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

Browse other questions tagged or ask your own question.