How to override the Parent theme Function into child themes functions.php

Check the parent theme’s functions.php. If properly written to support child themes, each of these functions should be wrapped in a conditional as follows:

if ( ! function_exists( 'theme_setup' ) ) :
function theme_setup() {
   // Parent Theme Setup Function Code
}
endif;
add_action( 'after_theme_setup', 'theme_setup' );

What this does is when the parent theme’s functions.php loads after your child theme, it will first check and see if your child theme already declared the function. If it has not, then it will go ahead and define it. Otherwise it will skip the function declaration and move on.

Just remember if you have to manually put these wrappers in, an update to the parent theme will overwrite them.

Leave a Comment

tech