开发者

Adding text before footer in wordpress

开发者 https://www.devze.com 2022-12-29 22:42 出处:网络
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

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


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.


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()


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号