Add Widget-ready Sidebars to Wordpress Footers

Now I have removed my Christmas theme formatting, I am ready to work more on my blog design.. Having made the move to Wordpress from Blogger not long before I added the festive colors and images, I had not spent any time on the real theme. I know I am doing this backwards - most sane people would decide on a theme before showing their blog face in public. The reason, I want to talk through the process I am going through as I do my design as a way of teaching anyone who may be interested.

To alleviate the problem of those resource hungry social networking widgets making page load time slow, I have now relegated them to the footer. Not being a php expert - (not much past the “hello dolly” stage) I had to search for a way of doing this. I had to piece together various bits of information here and there so I thought it an idea to put it all together for your edification and delight. (I am wondering how many left after reading the last part, thinking how boring). Anyone using anything other than Wordpress may as well take their leave at this point too, although I would much rather you click on recent posts or archives and stay a while longer on this blog of course.

Rather than having to add widget codes directly into my footer.php, I have added “sidebar” elements into the footer. This means I can add widgets to them from the Wordpress dashboard widget page, which gives me more flexibility if I change their content..

How to add a sidebar to a Wordpress footer

Firstly I had to tell Wordpress to insert new sidebars into my theme by altering the footer.php file.

As I already have two sidebars and wanted 3 columns in the footer, I needed to let the Wordpress architects know that instead of two sidebars I now needed 5. (the architects are those that work on the basic structure and design - in my imagination that is). For this I had to alter the functions.php file in my theme folder.

Edit functions.php:

Find the section in your theme folder’s functions php file that says something similar to the following- except the number will not be 5 yet:, it may be 1 or 2. Change the number to reflect how many sidebar elements you want in total (that is the number of sidebar(s) in your sidebar area plus how many you want in your footer) . If you do not have a functions.php file but have a widget enabled theme create the functions.php file including all of the code below.

<?php
if ( function_exists('register_sidebar') )
    register_sidebars(5,array(
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<h4>',
        'after_title' => '</h4>',
    ));
?>

Now the architects have drawn up their plans, the construction team come in to put the new sidebars in place. They need to build the new “sidebar” elements into the footer. I added mine at the very top of the footer straight after:

<div id="footer">

Add to footer.php:

<div id="footer-sidebar" class="secondary">
   <div id="footer-sidebar1">
     <?php if ( !function_exists('dynamic_sidebar')
      || !dynamic_sidebar(3) ) : ?>
     <?php endif; ?>
   </div>
   <div id="footer-sidebar2">
     <?php if ( !function_exists('dynamic_sidebar')
      || !dynamic_sidebar(4) ) : ?>
     <?php endif; ?>
   </div>
   <div id="footer-sidebar3">
     <?php if ( !function_exists('dynamic_sidebar')
      || !dynamic_sidebar(5) ) : ?>
     <?php endif; ?>
   </div>
</div> <!-- Close footer-sidebar -->
<div style="clear-both"></div>

I gave my new elements the id of “footer-sidebar” but you could call them anything you like as long as the name is unique - that is, different to any other id name you have in your theme.

That done, when your site loads, the builders come in and add the sidebars into the footer. Imagine how busy they are grabbing all the bits needed to put your page together.

The problem is the building is is still very basic. Now we need some interior designers to add a bit of style and finesse. Crack open your style.css file and pretty up the sidebars so they sit side by side of a width that is going to suit the sort of content you want in them. I made mine all the same width, measured so they stretch the full width of the footer: I gave the whole footer a border. I could have added borders around each sidebar, added background color etc, but wanted to keep it simple for these instructions.

Add to style.php

#footer-sidebar {
  border: 1px solid #cccccc;
  display:block;
  height: 260px;
}
#footer-sidebar1 {
  float: left;
  width: 300px;
  margin-right:20px;
  }
#footer-sidebar2 {
  float: left;
  width: 300px;
  margin-right:20px;
 }
#footer-sidebar3 {
  float: left;
  width: 300px;
 }

Note that the divisions have the same names as I gave them when adding them to footer.php

As, by the time you read this, I may have altered the formatting of the footer once more to add extra styling elements here is an image of what it looks like after adding the above styling.

Blogging Sueblimely

Popularity: 25% [?]

Sueblimely signature add to kirsty

RSS feed | Trackback URI

19 Comments »

Pingback by PlugIM
2008-01-11 14:17:28

Kramer auto Pingback[…] http://www.sueblimely.com Sueblimely submitted 8 minutes ago Now I have removed my Christmas theme formatting, I am ready to work more on my blog design.. Having made the move to Wordpress from Blogger not long before I added the festive colors and images, I had not spent any time on the real theme. I know I am doing this backwards - most […]SHARETHIS.addEntry({ title: “Add Widget-ready Sidebars to Wordpress Footers”, discuss trackback category: development problem? duplicate story bad link spam old news okay this is lame tags: blogging social networking add to: favorites   1 plug plug ‘EveryDay Qi’ Teleseminar at 8 pm EST […]

 
Comment by Shinade
2008-01-11 23:02:11

Hi Sue,
I am so glad that you dropped by. I have been working hard to rejoin all of my sites. And readd all of my friends and contacts.

I don’t find this boring at all and I am Blogger. I started once to make the move to wordpress but had problems working in it.

So I just know this site will help many!!
Happy New year Sue,
Jackie

Shinade’s last blog post..My Beautiful Loves

Comment by Sueblimely
2008-01-13 09:54:06

Hi Shinade, glad to see you up and running again and thanks for your kind comments.

(Comments wont nest below this level)
 
 
2008-01-13 06:14:37

Kramer auto Pingback[…] Your page is on StumbleUpon […]

 
Comment by Julien
2008-02-05 16:21:59

Impressive post. I havent found anything this good anywhere. Heads up!

For those interested and sceptical, if you put a little concentration into this it actually works.

Congrats!

Comment by Sueblimely
2008-02-05 19:32:39

Thanks Julien, it does take a bit of thinking about the first time you do it but you can add ’sidebars’ all over the place. :lol:

(Comments wont nest below this level)
 
 
Comment by Gaje Master
2008-02-22 07:50:44

Thanks for adding this, I have been trying to find a way to change my footer and this really helped. The only problem is that my hosting provider takes a long time before they update the main page and everything in my blog to follow what I want it to do. It has been known to take three days before it shows up right.

Comment by Sueblimely
2008-03-22 08:41:35

That is dreadful - 3 days! Just a thought though, have you considered it may be your browser cache that needs clearing out because it is storing your old information?

(Comments wont nest below this level)
 
 
Comment by JoLynn Braley
2008-03-05 17:26:22

Hi Sue, thanks so much for your tutorial, this was just what I was looking for!

JoLynn Braley’s last blog post..Tastes Great, More Filling - Mrs. May’s Naturals Snacks

Comment by Sueblimely
2008-03-22 08:49:39

I am glad - if there are other things you would like to learn please let me know as I am sure there are others who would be interested too :-)

(Comments wont nest below this level)
 
 
Comment by Random Guy
2008-03-22 03:50:54

I’m having a problem with this my sidebars aren’t showing horizontally. Does anyone knoe what I’m doing wrong?

 
Comment by Sueblimely
2008-03-22 08:47:24

As you have not left a link I can’t go and take a look but there could be a couple of reasons.

1. Your horizontal sidebar may not be styled to take up the full width of your blog but is taking on the width of your ordinary sidebar.

2. The information in the horizontal sidebar may not be styled to display horizontally. e.g. if it is a link list that will automatically take on the styling of your sidebar lists unless you style it to display horizontally - the CSS code for a horizontally displayed list should include display:inline;

Hope this helps.

Comment by Random Guy
2008-03-27 03:51:23
(Comments wont nest below this level)
 
 
Comment by Lisa
2008-03-30 04:32:47

Thank you for posting this. It’s the first time I’ve ever attempted to alter the code in WP this much and it worked!

Lisa’s last blog post..The Great Birthday Scam

 
Comment by Poppy Subscribed to comments via email
2008-04-12 10:38:33

Excellent, really clear, tutorial. Much appreciated!

 
2008-05-08 07:07:49

Kramer auto Pingback[…] blogs4God Member Posted 44 minutes ago # Hmmm … alot of interst on this topic. Okay, I’ll bite, here’s an article on the topic you may find useful entitled Add Widget-ready Sidebars to Wordpress Footers. […]

 
Comment by joao
2008-05-09 02:47:03

Hi,

Thank you very much, u re a life saver!
This post save me a lot of time
I will just try right now

Best regards,
Joao from Brazil

 
Comment by stuck!
2008-05-15 02:52:36

I followed the instructions, but it didn’t add any sidebars. When I go to the widgets page, it still has only 1 sidebar. Am I missing something?

 
Comment by jbj
2008-06-13 02:38:46

Thanks a lot for this great post. I just made a theme for my new blog and your knowledges helped me much!

jbjs last blog post..Python: 50 modules for all needs

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.

This site uses KeywordLuv by Stephen Cronin. Enter YourName@YourKeywords in the Name field and both will be shown. e.g. Sue from Blogging Sueblimely

WordPress | Based on The Sandbox