how to add another footer
-
I am wondering how to add another footer to this theme… is there a plugin to help do that or do I need to know code?
-
Can you tell me a little more about what you had in mind for a second footer?
Do you want to add additional widget areas, or some specific text or images, or something else all together?
yes… I want to have a 3 column widget area so I can put text links.
If you’re looking for a second row of widgets, you can add to the existing Footer Widget areas – the second widget in each area will be displayed below the first widget ??
Does that sound like what you had in mind?
Hey chad…
Actually no I wanted a whole separate footer… I would like to use a different background color to separate the footers. Does this require me changing the page templates php code?
I’d hoped to offer a CSS based solution by controlling the heights of the widgets and creating the appearance of a second footer – but because you’ve mentioned background color being a goal (thanks for that detail!) I don’t think that’s going to work.
You would indeed need to make some theme modifications – via a child theme. It’s going to be a bit of work, so here we go! ??
Fist, to register new sidebars (even though they’re in the footer, they’re still called ‘sidebars’).
In the
functions.php
file of your child theme, you can use a modified version of the the footer widget areas from the parent theme:function sela_secondary_footer_area() { register_sidebar( array( 'name' => __( 'Fourth Footer Widget Area', 'sela' ), 'id' => 'sidebar-8', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'Fifth Footer Widget Area', 'sela' ), 'id' => 'sidebar-9', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'Sixth Footer Widget Area', 'sela' ), 'id' => 'sidebar-10', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); } add_action( 'widgets_init', 'sela_secondary_footer_area', 12 );
I’ve copied the relevant block from the parent theme’s
functions.php
file. Then I bumped the sidebar numbers up to make them unique (the theme used 7 sidebars before, so these will be number 8, 9, and 10). I also changed the names to be the Fourth, Fifth, and Sixth Footer Widget Areas, respective.So, now the theme knows these items should exist. Next we tell it what they look like. Again, we can borrow from the parent theme. This time we’ll make a copy of
siderbar-footer.php
in our child theme, and rename it so it’s a new, unique sidebar file. Use a name likesidebar-secondary-footer.php
but make sure it starts with the word sidebar so the the get_sidebar() function can find it later.Now, go through the file and update the sidebar numbers again. All of the references to
sidebar-2
should becomesidebar-8
,sidebar-3
becomessidebar-9
and so on.You’ll also want to replace the HTML ID
tertiary
with something else, since we don’t want a duplicate ID on your page. You can name it pretty much anything you like, as it doesn’t look like the CSS targets it directly (not that I noticed anyway ?? ) I usedsecondary-footer-sidebar
.Here’s what it should look like in the end:
if ( ! is_active_sidebar( 'sidebar-8' ) && ! is_active_sidebar( 'sidebar-9' ) && ! is_active_sidebar( 'sidebar-10' ) ) { return; } ?> <div id="secondary-footer-sidebar" class="widget-area footer-widget-area" role="complementary"> <?php if ( is_active_sidebar( 'sidebar-8' ) ) : ?> <div id="widget-area-8" class="widget-area"> <?php dynamic_sidebar( 'sidebar-8' ); ?> </div><!-- #widget-area-8 --> <?php endif; ?> <?php if ( is_active_sidebar( 'sidebar-9' ) ) : ?> <div id="widget-area-9" class="widget-area"> <?php dynamic_sidebar( 'sidebar-9' ); ?> </div><!-- #widget-area-9 --> <?php endif; ?> <?php if ( is_active_sidebar( 'sidebar-10' ) ) : ?> <div id="widget-area-10" class="widget-area"> <?php dynamic_sidebar( 'sidebar-10' ); ?> </div><!-- #widget-area-10 --> <?php endif; ?> </div><!-- #secondary-footer-sidebar -->
Finally, we need to tell the theme to actually use our new new creation.
Your child theme now needs a copy of the parent theme’s
footer.php
file.Just below where it says this:
<?php get_sidebar( 'footer' ); ?>
You’ll add a call to your sidebar. The bit in quotes will be the name of your file, minus the word sidebar.
For example, if my new sidebar file from step one was
sidebar-secondary-footer.php
, then much function would look like this:<?php get_sidebar( 'secondary-footer' ); ?>
Once all of that is saved, you should be able to add widgets to the new widget areas. You can use CSS to change the background color as needed depending on what you replaced
tertiary
with.In my case, the CSS for the background would be:
#secondary-footer-sidebar { background: #999; }
Using whatever color you like, of course ??
Give that a go, and let me know what you think!
where is the function.php file located? what directory?
Your functions.php file will be in the folder you created when you set up your child theme.
All of the changes you’re making are in the child theme – you don’t want to edit the main theme directly, because those changes can be erased when the theme gets an update.
- The topic ‘how to add another footer’ is closed to new replies.