0

I have a parent theme with 2 widget areas, header, sidebar, and footer, the header and the footer have 2 simple text widgets in them.

When I switch to the child theme which consists of just style.css and functions.php to enqueue the stylesheet, both the widgets are removed, they are also not in the inactive widgets area.

Is there a method for ensuring that the widgets are not lost when the themes are switched?

1 Answer 1

0

I think you should check your parent theme functions.php for code which should load widgets and copy & paste such code to child theme functions.php file. It should work.

4
  • I tried this but I get a can not re-declare error, because the widget are does still exist when the child theme is activated it's just the widgets themselves that disappear.
    – Naz
    Dec 29, 2016 at 16:41
  • You should add such code to check if function already exists: if (!function_exists('functionName')) { function functionName(){ } }
    – Taras
    Dec 30, 2016 at 16:14
  • How will that help as the function will always exist?
    – Naz
    Dec 30, 2016 at 17:38
  • @Naz, in my example your child theme function will override parent theme function with the same name. It will remove possible errors in case if you use some functions in child theme which possible does not defined.
    – Taras
    Jan 3, 2017 at 12:34

Your Answer

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

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