3

I'm working with a handy responsive theme framework (Reverie) and I'm developing my own theme the right way using a Child theme. The Parent theme calls a sidebar called with an ID of 'Footer' and applies some basic styles to it. I want to adjust this in my child theme, so I was looking at perhaps filtering it but in the end I decided it'd probably be easiest to unregister the sidebar and re-register a new one with the proper classes in childtheme's functions.php.

Here's the code from the parent theme which declares the sidebar

$sidebars = array('Footer');
foreach ($sidebars as $sidebar) {
    register_sidebar(array('name'=> $sidebar,
        'id' => 'Footer',
        'before_widget' => '<div class="large-3 columns"><article id="%1$s"    class="panel widget %2$s">',
        'after_widget' => '</article></div>',
        'before_title' => '<h4>',
        'after_title' => '</h4>'
    ));
}

Yet, I'm not able to de-register the sidebar. I've attempted it, with the code below, but without any luck..

// Unregisters Reverie footer sidebar
 function remove_footer(){
    unregister_sidebar( 'Footer' );
}
add_action ('widgets_init, remove_footer', 11);

// Registers new footer array with proper classes

$sidebars = array('Childfeet');
foreach ($sidebars as $sidebar) {
    register_sidebar(array('name'=> $sidebar,
        'id' => 'Childfeet',
        'before_widget' => '<div class="small-12 medium-6 large-3 columns"><article id="%1$s" class="panel widget %2$s">',
        'after_widget' => '</article></div>',
        'before_title' => '<h4>',
        'after_title' => '</h4>'
    ));
}

My new sidebar with proper classes is of course created, but it seems like my remove_footer() does not do it's job. Any ideas?

I have checked out all the other 'unregistering sidebar' posts here in the forums, but these all contain errors in functions which I can't see in my code.

Thanks a bunch for your time!

  • 1
    Your parent theme is probably _doing_it_wrong() by calling the sidebar directly from functions.php instead of defining them in a function and calling them via the widgets-init hook. If that's the case then unregistering via the widgets-init hook isn't going to work. I'm not sure if trying a different hook for your removal function (after_setup_theme, maybe?) would work, and even if it did, the whole thing would be highly unorthodox and may result in other problems down the road, so proceed with caution! – Caspar Jul 21 '14 at 15:38
2

It should be possible to use the after_setup_theme hook to unregister the sidebar you don't want like this:

function go_away_extra_sidebar(){
    unregister_sidebar( 'Footer' );
}

add_action( 'after_setup_theme', 'go_away_extra_sidebar' );

Happy Coding,

Kuchenundkakao

0

Thanks for your help fellas! The after_setup_theme() function was a new one for me which is probably going to be very helpful down the line. Unfortunately my error was something simpler. When I called the unregister_sidebar function..

add_action ('widgets_init, remove_footer', 11);

I was missing the proper quotes around each function. It should read.

add_action ('widgets_init', 'remove_footer', 11); 

It removes the Footer sidebar as expected. :-(

Thank you for helping me track it down!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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