Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How do I change the footer area to have three widget areas?

The Reactor Theme has one footer widget area. It separates into three columns if more than one widget is added but I find that difficult to balance up with more than three widgets being used. So, I tried to change it to three widget areas in the footer.

I have done this before but not in a theme that spreads itself out in the way that Reactor does with all those functions, hooks, actions and stuff. Anyway, I had a go at changing the code in two files and I have put that here:

http://pastebin.com/MA4nrPBq

I want to get three footer widgets in my admin area but not on my page. I think I have the right code to edit but how do I edit the code to move this on?

Thanks

Martin

Here's the code I am trying:

//In sidebars.php

        if ( in_array( 'footer', $sidebars[0] ) ) {
                $footer  = '<div id="%1$s" class="widget top-bar-widget ';
                $footer .= 'large-' . reactor_get_widget_columns('sidebar-footer-01'); //Added -01
                $footer .= ' columns %2$s">';
                register_sidebar( array(
                        'name'          => __('Footer 01', 'reactor'), //Added 01
                        'id'            => 'sidebar-footer-01', //Added -01
                        'description'   => 'Footer widget area',
                        'class'         => '',
                        'before_widget' => $footer,
                        'after_widget'  => '</div>',
                        'before_title'  => '<h4 class="widget-title">',
                        'after_title'   => '</h4>',
                ) );
        }
        if ( in_array( 'footer', $sidebars[0] ) ) {
                $footer  = '<div id="%1$s" class="widget top-bar-widget ';
                $footer .= 'large-' . reactor_get_widget_columns('sidebar-footer-02'); //Added -02
                $footer .= ' columns %2$s">';
                register_sidebar( array(
                        'name'          => __('Footer 02', 'reactor'), //Added 02
                        'id'            => 'sidebar-footer-02', //Added -02
                        'description'   => 'Footer widget area',
                        'class'         => '',
                        'before_widget' => $footer,
                        'after_widget'  => '</div>',
                        'before_title'  => '<h4 class="widget-title">',
                        'after_title'   => '</h4>',
                ) );
        }
//The above code is just a copy of Reactor code.  I just added the 01, 02 and did it 4 times.

//In sidebar-footer.php

                <?php if ( is_active_sidebar('sidebar-footer') ) : ?>
            <div class="row">
                <div class="<?php reactor_columns( 12 ); ?>">
                    <div id="sidebar-footer" class="sidebar" role="complementary">
                      <?php dynamic_sidebar('sidebar-footer-01'); ?> //Added -01
                      <?php dynamic_sidebar('sidebar-footer-02'); ?> //Added line
                      <?php dynamic_sidebar('sidebar-footer-03'); ?> //Added line
                    </div><!-- #sidebar-footer -->
                </div><!--.columns -->  
            </div><!-- .row -->
                <?php endif; ?>
share|improve this question
    
I changed the code a bit more (and edited the past bin) and now I get the widget areas in the dashboard and on the page. –  martcol Nov 15 '13 at 14:55
    
Please edit your question and include your relevant code inline, rather than linking to a third-party site. –  Chip Bennett Nov 15 '13 at 15:08
    
I added my code, sorry about that. I don't want my code written for me. I mostly want to know how to go about it. I can see that I will have to change classes and some other elements but it's the getting the widget areas in that I am interested in. I can see that Reactor is clever because it divides the footer into columns according to the number of widgets you add. –  martcol Nov 16 '13 at 10:17
    
Please edit your question to be a question. "I get three footer widgets in my admin area but not on my page", is a statement not a question. –  jb510 Nov 18 '13 at 23:40

1 Answer 1

up vote 0 down vote accepted

Note in the code you gave for sidebar-footer.php

<?php if ( is_active_sidebar('sidebar-footer') ) : ?>

...is always going to return false since that no longer exists.

Since this is a custom theme you can probably just comment out or remove that line and it's endif pair since I trust you always want the markup to output even if the 3 sidebar areas are empty.

Alternatively:

 <?php if ( ( is_active_sidebar('sidebar-footer-01') || ( is_active_sidebar('sidebar-footer-02') || ( is_active_sidebar('sidebar-footer-03') ) ) : ?>
     <div class="row">
         <div class="<?php reactor_columns( 12 ); ?>">
             <div id="sidebar-footer" class="sidebar" role="complementary">
               <?php dynamic_sidebar('sidebar-footer-01'); ?> //Added -01
               <?php dynamic_sidebar('sidebar-footer-02'); ?> //Added line
               <?php dynamic_sidebar('sidebar-footer-03'); ?> //Added line
             </div><!-- #sidebar-footer -->
         </div><!--.columns -->  
     </div><!-- .row -->
 <?php endif; ?>
share|improve this answer
    
that is really helpful. Thank you for adding that code, it helps me a lot. I think it might be missing a couple of closing brackets though. –  martcol Nov 19 '13 at 14:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.