How to Create a Secondary WordPress Footer for Select Pages (Widgetized)

Wordpress Create Footer

Wordpress Create FooterThe fun part of digital marketing are the unpredictable situations you find yourself. I consider myself a relatively smart guy, but even I come into situations that make me say, “hmmmmm.”

Here is a tutorial on how to create a secondary Wordpress Footer to appear on select pages, and how to make it widgetized. When finished you will have unique footers show up for pages on your website, so the Contact Page can have a different footer than the Index Page.

This is a low to medium level tutorial and basic HTML, CSS, PHP and WordPress architecture knowledge is recommended.

 

 

 

 

[line] [column width=”1/2″ first=”yes”]

Synopsis:

A client wants a different footer on the “contact page” of his WordPress website. The client desires that the main footer stay the same on all other pages except the “contact page.”
So essentially he wants two footers. The client also needs the footer to be widgetized so he can manage text and links in the future.

[/column] [column width=”1/2″ last=”yes”]

Approach:

I reviewed his WordPress site, footer.php, functions.php and sidebar.php files to see how everything is currently functioning.
I noticed the footer was already widgetized and that I would now have to create a separate footer for the contact page.[/column]

This it how it was done.

Step 1: Duplicate the Sidebar Footer:

First, let’s create a new sidebar. Your template should/might have a ‘sidebar-footer.php.’ You need to duplicate ‘sidebar-footer.php’ and rename it to ‘sidebar-footer2.php.’
[NOTE: This sidebar will be your second footer widget. You will be able to add Widgets to the footer.]

Every sidebar.php file is different depending on the WordPress template you have. In general you need to replace any script that relates to the sidebar.php, with the below snippet.

[box color=”gray” icon=”config”]<?php dynamic_sidebar(‘sidebar-footer2’); ?>[/box]

Step 2: Duplicate the WordPress Footer

Second, we will need to create the a new “Footer File” by duplicating the current ‘footer.php’ and renaming the new file ‘footer2.php’. (You can name it whatever you wish, like “footercontact.php”).

[box color=”green” icon=”check”]

Now you have two footer pages:
1. footer.php (the default main footer)
2. footer2.php (the contact footer)

[/box]

The code inside the footer file will be different for every WordPress template. The following snippet connects the “Widgetized” sidebar, so you can add “Widgets” to the footer.

[box color=”gray” icon=”config”]<?php get_sidebar(‘sidebar-footer2’); ?>[/box]

Step 3: Connecting pages to WordPress Functions.php

The next step is to find the functions.php file. We need add some snippet to the ‘functions.php’ file, which will connect WordPress infrastructure to the files you just created above (‘footer2.php’ and  ‘sidebar-footer2.php).

The next step is to find the place in the ‘functions.php’ file with sidebar code, usually it looks like this: // Sidebars.

Add this snippet:

[box color=”gray” icon=”config”]register_sidebar(array(
‘name’ => __(‘Footer sidebar 2’, ‘blm_basic’),
‘id’ => ‘sidebar-footer2’,
‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</li>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’
));[/box]

Step 4: Adding Snippet to Index.php

Then, find your Index.php file. You are gonna add a little snippet at the bottom.

[box color=”gray” icon=”config”]<?php
get_sidebar();
if (is_page(‘contact’)) { include (TEMPLATEPATH . ‘/footer2.php’); } else { get_footer(); }
?>[/box] [quote align=”right”]“ Cool right!”[/quote]

Extra Step: Add New Footer to other pages

Now, if you want to add the NEW footer2.php to other pages just use the below code. Obviously change the names of the files to correspond the pages you want.

[box color=”gray” icon=”config”]<?php
get_sidebar();
if (is_page (‘contact’)|| is_page(‘programs’) || is_page(‘about-us’)) { include (TEMPLATEPATH . ‘/footer2.php’); } else { get_footer(); }

?>[/box]

If this article helped you, please leave me a comment. It’s great to know that I helped someone out.

One thought on “How to Create a Secondary WordPress Footer for Select Pages (Widgetized)

Leave a Reply

Your email address will not be published. Required fields are marked *