I am trying to override some behaviour in a parent theme (Blackoot Lite) and used this StackOverflow question as a guide.

My goals are twofold—I want to unregister a default sidebar in the parent theme, plus I want to add a custom header widget area. Neither thing ends up happening. 😒

Below is my code, which I put into the child theme's functions.php:


add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );

function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );

function wpb_widgets_init() {

    register_sidebar( array(
        'name'          => 'Custom Header Widget Area',
        'id'            => 'custom-header-widget',
        'before_widget' => '<div class="chw-widget">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2 class="chw-title">',
        'after_title'   => '</h2>',
    ) );

add_action( 'widgets_init', 'wpb_widgets_init' );

function blackoot_lite_unregister_sidebar() {
add_action( 'after-setup-theme', 'blackoot_lite_unregister_sidebar' );

Any advice would be much appreciated.

  • What did you change regarding other template files?
    – D. Dan
    Jan 17, 2018 at 9:08
  • I didn't make any other changes. All of the googling I did indicated that I only had to add that code to functions.php and that was sufficient. I read a bunch of tutorials, but they were for older versions of Wordpress and had contradictory information. Jan 17, 2018 at 9:15
  • Should I be using a filter? I considered that first, but thought maybe it was overkill. Jan 17, 2018 at 9:18
  • Well if you want to add a widget area in the header, the you should add code to the header.php also: if ( is_active_sidebar( 'particular-sidebar' ) ) dynamic_sidebar( 'particular-sidebar' ); You could also remove the unwanted sidebar by removing these lines. But first you should find these places in the parent theme, copy those files over to your child theme, and change them accordingly. Also you should check in your parent theme where is the widget added, and remove it according to that. "after-setup-theme" may not be a good 'place'.
    – D. Dan
    Jan 17, 2018 at 9:28
  • 2
    the action after-setup-theme doesn't exist in WordPress core. it may be the action after_setup_theme ?
    – mmm
    Jan 17, 2018 at 10:10

1 Answer 1


You may find this useful to understand how to add a widget area in WP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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