How To Show A Different Footer On Your Home Page, Blog Posts And Pages

Most WordPress websites use the same footer throughout their site. What few people know is that it’s actually very easy to show different footers throughout their site using the get_footer function. Using this function you could easily display different sized footers with different content throughout your site.

For example, you could show:

  • A large footer area on your home page with featured posts from your website.
  • A medium sized footer on your posts (single.php) that displays related posts.
  • A small footer on your pages that links to important areas of your site like advertising, archives, sitemap etc.
  • A custom footer for your 404 page that shows categories and archive links.

Remember, to do this we need to use the get_footer function. Don’t get it confused with the function wp_footer. wp_footer is placed before the closing body tag and used by scripts to insert Javascript and ad tracking codes.

The get_footer Function

The get_footer function only has one parameter; a string that is used to call the correct template.

<?php get_footer( $name ); ?>

Most themes use this function with no parameters. When a template such as index.php, page.php or single.php uses get_footer() at the bottom, it inserts the footer.php template. By entering a parameter you can make WordPress call a different template.

For example, if we add this to our single.php template (i.e. the template that is used to display posts):

<?php get_footer('single'); ?>

Then WordPress will insert a template called footer-single.php. Likewise, we could use get_footer(‘page’) to call footer-page.php on pages (page.php), get_footer(‘index’) to called footer-index.php for our home page (index.php) and get_footer(’404′) to call a template called footer-404.php for our 404 error page (404.php).

It only takes a minute to create your custom template. Most of your time will be spent customising it. Let’s walk through the 3 simple steps required to create a custom footer for your pages. As you know, the WordPress page template is called page.php.

  1. Copy the code from your existing footer.php template and place it in a file called footer-page.php.
  2. Upload footer-page.php to your theme folder.
  3. Open your page.php template via the WordPress theme editor or via a text editor on your computer and look for the call to get_footer() at the bottom of the page. Simply change this to get_footer(‘page’). Save the file (or save and upload if you edited the file on your computer).

Your pages will now insert content from footer-page.php rather than your normal footer.php template. All you need to do is customise your footer-page.php accordingly. It’s up to you how little or how much you change. For example, you could simply use this technique to display a different footer background colour on pages. Perhaps you will keep the same colour scheme and style and simply change the information that is displayed on pages. Alternatively, you could change the layout, colour scheme and content and make it unrecognisable from the original footer.

Displaying Different Footers Using Conditional Tags

Those of you who read my recent article about making WordPress titles SEO friendly will know that it’s very easy to control what content is displayed in different areas of your site using conditional tags.

For example, if your theme doesn’t use category.php and date.php to display category and date archives, you could use the following in index.php to display a different footer on your home page, category archives and date archives:

<?php
if ( is_home() ) :
  get_footer('home');
elseif ( is_category() ) :
  get_footer('category');
elseif ( is_date() ) :
  get_footer('date');
else :
  get_footer();
endif;
?>

Note that it’s only useful to use conditional tags for templates that are used for many different areas of your site. Index.php is a prime example of this as it is the fall back template for all templates. If there is no 404.php template, index.php is used, if there is no search.php template, index.php is used. The same goes for taxonomy.php, tag.php, home.php, date.php, archive.php, category.php, single.php, page.php, author.php and attachment.php.

If your theme is missing any of these templates then it will be using index.php instead. If that is the case, you should conditional tags to control what footer is displayed on your site. If your theme does have a dedicated template for a page or area (e.g. author.php for author profiles or category.php for category archives) then you should edit those templates directly instead using get_footer( ‘name’).

An Example

I’ve been playing around with over the last day or so. I may still change things around a little however at the moment I have the following setup.

On the home page I show the first two featured posts at the top of the page, therefore on the home page footer I display the 3rd, 4th and 5th featured posts.

Home Page Footer

On my archive pages I show the the 3 latest featured posts at the top of the page and the 4th, 5th and 6th latest at the bottom of the page.

On blog posts and category archives I show the last 3 featured posts from that category. In the footer the 4th, 5th and 6th featured post from the corresponding category are displayed. I could have used the same template for both categories and posts however I used footer-single.php and footer-category.php just incase I want to customise the footer more later.

Post Footer

On all other pages I display a minimal footer template with some credit links.

Page Footer

It only took me a few minutes to set this up. I can now dictate what featured posts are displayed on my footer in different areas of WP Mods to encourage more visits to premium articles.

Overview

The great thing about the WordPress template system is that it makes customising different areas of your website so easy. Very few websites take advantage of the get_footer function though it’s something that is always available, if only to show slightly different content or a different colour scheme on other areas of your site.

If there is any part of this article you are unsure about, please leave a comment or post a thread in the WordPress forums and I’ll do my best to help :)

Kevin

This article was authored by:

Kevin Muldoon is a professional blogger with a love of travel. He writes regularly about topics such as WordPress, Blogging, Productivity, Internet Marketing and Social Media on his personal blog and and provides technical support at Rise Forums. He can also be found on Twitter: @KevinMuldoon and Google+.

Kevin Muldoon has authored 830 posts.Visit Website

Showing 14 Comments

  • Nice tip thanks Kevin

    REPLY
  • I recently shifted my website to wordpress and was searching for some good tutorials. Nice to find you Kevin, I am going through all the resources given here. Can you please tell me about the resource box like yours (About The Author) where can I get it thanks.

    REPLY
  • Kevin Muldoon (Admin)

    The author box is box is built into the theme however I recommend checking out WP Biographia.

    REPLY
  • The question might be somewhat relevant, I want to use different single.php file for pages. How can I do that?

    REPLY
  • Kevin Muldoon (Admin)

    I’m not sure why you would want to do that. Though if you do want to, the easiest thing would be to just copy the code from your single.php file to your page template.

    REPLY
  • Unebliveable how well-written and informative this was. This is my first time I have visited this site. I found a lot of interesting information in your blog. From the volume of comments on your posts, I guess I am not the only one! keep up the great work.

    REPLY
  • dreamy

    Hi Kevin,
    nice post !!
    Can you please help me in this, I want to add the title of every post in the footer, that means for every post the footer should be having a different value, say the post title is ‘Hello World’ so i want to show this title in the footer also.
    so how can I do that? please help
    Thanks :)

    REPLY
  • Kevin Muldoon (Admin)

     @dreamy I haven’t done this myself yet though you should be able to do this by creating a footer-single.php template and the query posts function.

    REPLY
  • Kevin Muldoon (Admin)

     @dreamy  I haven’t done this myself yet though you should be able to do this by creating a footer-single.php template and using the query posts function.

    REPLY
  • How easy is this to scale on a completely dynamic basis?

    REPLY
  • How difficult would it be to post specific information in the footer using categories? For example, my site deals with TV Shows. I would like the Walking Dead posts to display a link in the footer to the DVD at amazon.com (instead of having to paste the code each time I create a new post). I’ve been looking for a plugin for this, but not having any luck, thought I would ask. Thanks Kevin.

    REPLY
  • Kevin, that is awesome. Thanks!

    REPLY
  • I don’t have in Virtue Theme a file called page-footer ?? any solution thank u

    REPLY
  • Thanks! This helped me figure out a problem that I had with a page template. (even though your post is on a little bit different topic… :))

    REPLY

Add Your Voice: