Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding text before footer in wordpress

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

like image 662
jake Avatar asked May 10 '10 06:05

jake


People also ask

How do I edit text in a footer on WordPress?

Sign in to your WordPress dashboard. Go to Appearance → Customize. In the website customization menu, click on Footer. You can edit the footer by using widgets to add new sections or by editing the content and style of the footer bar.

How do I arrange the footer in WordPress?

To access the Customizer, go to Appearance -> Customize in your WordPress dashboard. Here's what to look for to edit the footer in the WordPress Customizer: Theme Options – you might find a Theme Footer section where you can customize the colors, border, and text of the footer to fit the site's overall design.

How do I customize header and footer in WordPress?

Go to WordPress Dashboard > Templates > ThemeBuilder. Click Add New Template and choose Header (or Footer) Name your header template and click Create Header (or Footer) Now you'll be able to either choose a premade header (or footer) template or create one from scratch.


2 Answers

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.

like image 68
John P Bloch Avatar answered Oct 12 '22 19:10

John P Bloch


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

like image 36
Ozh Avatar answered Oct 12 '22 19:10

Ozh