Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a 3 column dynamic widget footer in Wordpress theme

My wordpress theme does not have a widgetised footer area. All there is is just a

footer text

in the footer.

I want to be able to add widgets in my footer from the widgets area in dashboard, such as blogroll, site pages, recent posts etc. I want the footer to be 3 columns.

How can I do this? cheers

like image 316
pab Avatar asked Nov 29 '22 02:11

pab


1 Answers

You'd first of all register your widget areas in functions.php;

/* REGISTER WIDGETS ------------------------------------------------------------*/

if (function_exists('register_sidebar')) {
    register_sidebar(array(
        'name' => 'Footer Left',
        'id'   => 'footer-left-widget',
        'description'   => 'Left Footer widget position.',
        'before_widget' => '<div id="%1$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2>',
        'after_title'   => '</h2>'
    ));

    register_sidebar(array(
        'name' => 'Footer Center',
        'id'   => 'footer-center-widget',
        'description'   => 'Centre Footer widget position.',
        'before_widget' => '<div id="%1$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2>',
        'after_title'   => '</h2>'
    ));

    register_sidebar(array(
        'name' => 'Footer Right',
        'id'   => 'footer-right-widget',
        'description'   => 'Right Footer widget position.',
        'before_widget' => '<div id="%1$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2>',
        'after_title'   => '</h2>'
    ));


}

Then in your footer.php file you'd have something like this;

    <!-- footer -->
    <div id="mainfooter">

        <!-- 1/3 -->
        <div class="four columns">
            <?php if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar('footer-left-widget') ) ?>
        </div>
        <!-- /End 1/3 -->
        <!-- 2/3 -->
        <div class="four columns">
            <?php if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar('footer-center-widget') ) ?>
        </div>
        <!-- /End 2/3 -->
        <!-- 3/3 -->
        <div class="four columns">
            <?php if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar('footer-right-widget') ) ?>
        </div>
        <!-- /End 3/3 -->

    </div>
    <!-- /End Footer -->
like image 98
McNab Avatar answered Dec 05 '22 22:12

McNab