• Resolved andrewcrook

    (@andrewcrook)


    G’day

    I’m doing a bit of customizing using a child theme, but I’ve run into a roadblock.

    I’ve modified the Customizer options in /inc/customizer.php, but the child theme version of the file isn’t being called. It’s still using the file in the parent theme because of the call

    require get_template_directory() . '/inc/customizer.php';

    As far as I know, it’s not possible to ‘unrequire’ a file and replace it with the child version. This can be fixed by changing this line in the parent theme to

    require get_stylesheet_directory() . '/inc/customizer.php';

    We obviously don’t want to change the parent theme, as they’ll be lost when the theme updates.

    I’m hoping the developer will be able to make this change in the next update to allow for better child-theme support.

    Is there any other way to achieve this by not editing the parent them?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Andrew,
    normally to modify a core template php file like that, one needs to unhook the original function via the child theme’s functions.php and THEN add back your new modified version of the function.

    An alternative way is that you can modify (in some cases) the name of the function that is being called in your child theme template files and then create a duplicate of the original theme’s php customizer with a NEW function name, that you call in your modified child theme template (essentially leaving the original function and php code alone)

    If I’ve misunderstood your question, feel free to elaborate so I can try to help further 😉

    Best!
    Steve

    If we used get_stylesheet_directory in the parent theme, and someone created a child theme but did not provide a /inc/customizer.php file in their child theme, it would give them a white screen and their site would crash because the required file would be missing in the child theme. Using include instead of require would prevent the white screen, but simply would not load the one from the parent theme.

    There are other workarounds, like locate_template, but we chose to stick with the recommendations from WordPress.com since we’re also submitting the theme there for inclusion in their theme directory.

    If you want to extend the customizer options with your own, you could just include those in your child theme’s functions.php and let both the parent and the child load their customizer options. You could also unhook the Editor customizer functions, using something like remove_action( 'customize_register', 'editor_customizer_register' ); and add your own.

    Thread Starter andrewcrook

    (@andrewcrook)

    Thanks BabyFaceWeb and mindctri, I’ll try your suggestions and let you know how I go!

    Thread Starter andrewcrook

    (@andrewcrook)

    Thanks mindctri

    I took your advice and added my own customizations to a new function, which appended my fields to the customizer, as I only wanted to add (not remove) fields. I followed this tutorial for tips: http://code.tutsplus.com/tutorials/a-guide-to-the-wordpress-theme-customizer-adding-a-new-setting–wp-33180

    Nice Job Andrew!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Poor child-theme support?’ is closed to new replies.