问题
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
回答1:
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()
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/2800778/adding-text-before-footer-in-wordpress