views:

120

answers:

3

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

A: 

The code you provided should work.

Are you certain that you added it in the activated theme? And in functions.php in the root of that theme? You should find the theme folders in <root>/wp-content/

Your alternative is to add the content directly into the "footer.php" of your theme. Depending on the type of content this may be the better and simpler option.

Greg
+2  A: 

Your code is valid. Just make sure your theme actually fires the "wp_footer" action: somewhere in footer.php probably there must be either do_action('wp_footer') or wp_footer()

Ozh
This did it. my theme footer.php did not call wp_footer();. I've added it and now it works like a charm
jake
+1  A: 

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.

John P Bloch