Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Changing WP Customizer on a Child Theme

Hi, I need to customize a parent theme's customizer so I've made a child theme. I've completed the WordPress Customizer API course but I want to know if there are any special things I need to do since it's a child theme or if I can just follow the same principles as shown in the video.

Thanks!

2 Answers

I was under the impression that you could override specific functions from the parent theme in the child theme's functions.php? It would actually be more like 'under-riding' though as the child theme's functions.php is actually loaded prior to the parent theme.

It would rely on the functions within the parent theme being written in the following manner as well...

// themes/parent/functions.php
if ( ! function_exists( 'theme_special_nav' ) ) {
    function theme_special_nav() {
        //  Do something.
    }
}

So my thinking is that by including the following in the child theme functions.php it would take priority and allow you to force the functionality from the child theme over the parent...

// themes/child-theme/functions.php
function theme_special_nav() {
    //  Do something.
}

I will say I haven't actually tried this for myself! I was just flicking through the forum and thinking out loud :-)

Thanks so much!

Hey Liz!

You should just be able to follow the steps to add new functionality because Wordpress child themes supersede parent themes.

It can be difficult to take functionality away because functions.php is not superseded by the child theme and this is the file which calls theme-customizer.php.

I was looking into it and came across this thread which you might find useful: https://wordpress.org/support/topic/removing-controls-and-settings-set-in-parent-from-child-theme

Good luck!

Thanks! That's great!