views:

15

answers:

2

I want to add sidebars or widgets to wordpress theme, I tried many tuts online but they failed because they are to outdated. My website link is here

http://lifetothebrim.com

 I want to add sidebar in three column layout.

Thank you

A: 

codex it's not outdated http://codex.wordpress.org/Function_Reference/get_sidebar, this might help you.

omabena
A: 

How to add a sidebar in the footer of a WordPress theme


Step 1.

Register your sidebars in functions.php

if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'name' => 'Footer Widgets Left',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));

if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'name' => 'Footer Widgets Center',
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
        ));


if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'name' => 'Footer Widgets Right',
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
        ));

Step 2.

Create a template file and name it sidebar-footer.php and include the call to your sidebar

<div class="footer-left>

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widgets Left') ) : ?><?php endif; ?>

</div>
<div class="footer-center">

   <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widgets Center') ) : ?><?php endif; ?>

</div>

<div class="footer-right">

   <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widgets Right') ) : ?><?php endif; ?>

</div>

Note: for styling purposes you should wrap the above function call in a div

I broke it into 3 widget areas for you with the css clases "footer-left", "footer-center", and "footer-right"

You will have to add the styles to display them in your css.

Example: clear any floated divs that come before this.

.footer-left {width:300px;float:left;} .footer-center {width:300px;float:left;} .footer-right {width:300px;float:left;}

make sure the next div clears:both

Step 3.

In your footer.php or at the bottom of any of your templates add

<?php get_sidebar('footer'); ?>
Chris_O
Hi Chris, I tried this
mjb
but it didnt worked, I downloaded another theme from same designer this new theme have sidebars in footer below is the code
mjb
<div id="one-col"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar One Column') ) : ?> <?php endif; ?> </div> <!-- end #first-col --> <div id="first-col"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Right Column') ) : ?> <?php endif; ?></div> <!-- end #first-col --> <div id="last-col"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Left Column') ) : ?> <?php endif; ?> </div> <!-- end #last-col -->
mjb
In footer.php <div class="container clearfix"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer') ) : ?> <?php endif; ?> <div class="clear"></div>
mjb
there is no register function in functions.php
mjb
I tried to add this code into my theme but it is not working, please suggest .
mjb
I broke it down into 3 widget areas for you left, center, and right. And added some basic css structure. Follow the directions exactly as written it works. I always test my code before I submit an answer.
Chris_O
Hi Chris, I am really grateful to you for your help I tried the new solution but still it gives me the same error I have followed your steps carefully but after completing the first step it gave me error I have uploaded the theme files here http://hotfile.com/dl/71610238/e022ca0/SimplePress.zip.html Please if possible edit theses file, I am really grateful to you for your help. Thank you
mjb
@user427393 I have already correctly answered the question.
Chris_O