Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Simon Zupan
PLUS
Simon Zupan
Courses Plus Student 183 Points

Hi! How can I create the same footer text to appear at the bottom of each blog post? Thank you!

I wonder how can I create the same footer text to appear at the bottom of each blog post?

Joel Brennan
Joel Brennan
18,300 Points

Hi,

There are 3 different methods explained here: https://ithemes.com/2011/03/20/automatically-add-content-to-your-wordpress-posts-and-pages/

Is that the sort of thing you are looking for?

I guess you may also be able to 'hardcode' it into your template inside the loop if you wanted to display it on a certain template only.

1 Answer

Sam Donald
Sam Donald
36,305 Points

If it's the same for everywhere on the site (i.e. all pages including a static front-page if you use one, and posts).

  1. Create a footer.php file.

  2. Your sites closing

    </body>
    

    and

    </html> 
    

    tags should be in this file.

  3. Above/before your closing

    </body>
    

    tag write your footer code.

  4. Example...

<footer>
    <div id="footer-wrapper">
      <ul id="footer-contact">
          <h3>Contact Us</h3>
          <li>1300 123 456</li>
          <li>example@footer.mail</li>
          <li>47 Example For Footer SA 3542</li>
      </ul>
      <ul id="footer-legal">
          <h3>Disclaimer</h3>
          <li>This footer has been made as an example for a Treehouse question. It is meant for demonstration puposes only</li>
          <li>Released under Creative Commons</li>
      </ul>
    </div>
</footer>
<?php wp_footer(); ?>

</body>
</html>
  1. You'll notice that line immediately after the closing

    </footer>
    

    tag, wrapped in a php block. That's an important piece of code. It tells Wordpress where to place important files including scripts etc...

  2. Place the code

    <?php get_footer() ?>
    

    at the very bottom of any page you want footer.php to appear (i.e. index.php, front-page.php etc...)

Note: You can obviously construct this footer.php page with php code, but this is just a simple example for what to do if you want exactly the same thing everywhere.