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
:
<?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() {
unregister_sidebar('sidebar');
unregister_sidebar('footer-sidebar');
}
add_action( 'after-setup-theme', 'blackoot_lite_unregister_sidebar' );
Any advice would be much appreciated.