Support » How-To and Troubleshooting » Adding Widget Areas to Child Themes
4 years, 9 months ago
I want to create a child theme (of TwentyTen) that has custom widget areas. The problem I’m having is that the child functions.php file, of course, doesn’t override its parent theme’s functions.php file (unlike style.css).
Because of this, I’m unable to run the register_sidebars function twice, and thus register new sidebars. I’m wondering if there’s a way to add a widget area to a child theme without taking out the register_sidebars function in the parent theme.
Any help is much appreciated. Thanks!
4 years, 8 months ago
You can certainly add sidebars in a child theme. You can call register_sidebar() as many times as you need to register your sidebars.
You will need to create one or more sidebar-mysidebar.php files and place a call to get_sidebar(‘mysidebar’) in the proper template files to actually display each sidebar.
I also found the following explanation:
Is it always necessary to use the add_action hook to register a widget area in a child theme?
I don’t think that an action hook is necessary, but it does guarantee that the sidebar registration will be done at the correct time.
See the Codex article on Widgetizing Themes, and this tutorial.