Adding text before footer in wordpress

jake picture jake · May 10, 2010 · Viewed 15.8k times · Source

I've been reading the wordpress codex and it seems that if I want to add some text just before the footer shows up I should use code like this in my functions.php

add_action('wp_footer', 'your_function');

function your_function() {
  $content = '<p>This is inserted at the bottom</p>';
  echo $content;
}

It is my understanding that the $content should show up just before the footer, but it does not show up at all. Is there another way to show up my code just before the footer ?

I am with WP 2.8 but this should not matter

Answer

John P Bloch picture John P Bloch · May 10, 2010

If you want to add something right before the footer (not in the middle of it), use

add_action('get_footer', 'your_function');

That hook runs when the theme file calls the get_footer() function.