Adding Sidebars to a Child Theme
-
So I’m rocking and rolling with child themes, making some really cool changes to them by adding functions to the child themes functions.php file. I’m actually building a library of code that I can apply to any theme to handle the navigation the way I want, display excerpts instead of full blog posts, etc.
However, the one thing that is killing me that I can’t seem to figure out is how to add sidebars in the child theme while leaving the parent’s sidebars alone. Since the child’s functions.php loads first, it doesn’t know anything about the parent’s functions.php yet so my new sidebars show up first and then the parent’s sidebars show up last. However, in almost all cases that I can think of, I want the parent’s couple of “standard” sidebars (sidebar and footers usually) to remain in tact, still populated with my widgets from other themes that use the standard “sidebar 1” and then have my cool new stuff show up after that.
To me this is a big problem with WordPress themes in general that every time we switch themes we totally screw up all of our sidebars, but I’d at LEAST like the one main sidebar to remain in tact. Does anyone have a suggestion on how to do that?
I’ve tried declaring the parent themes sidebars in my child theme, using the same name and even giving it a matching id. I thought those would be required to be unique, but I end up with two copies of each of the parent’s themes sidebars.
I can’t use an unset function to remove the parent’s sidebars, because they don’t exist yet. I don’t see a filter that can be applied to stop the parent from registering its sidebars using unregister_sidebar().
Surely there is some way to do this, right?
The topic ‘Adding Sidebars to a Child Theme’ is closed to new replies.