Last Updated: February 25, 2016
·
1.522K
· randy

(Working with child themes) Deregister & Override WordPress twentyeleven sidebar

Anyone interested in creating a child theme to be used in conjunction with WordPress twentyeleven (parent) theme will, at some point, come across the need to override functions within parent theme.

Here is how your child's function.php should read when trying to deregister and override the widgetized sidebar found in the twentyeleven theme:

// !AFTER_SETUP_THEME
add_action( 'after_setup_theme', 'randy_setup' );
function randy_setup() {

/* Remove the twentyeleven registered sidebars */
remove_action( 'widgets_init', 'twentyeleven_widgets_init' );

function randy_widgets_init() {
(replaced code, copied and edited from parent theme)
}
add_action( 'widgets_init', 'randy_widgets_init' );
}

Learn more about WP aftersetuptheme: http://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme