Theme function extensions
I'm not an expert but for me the only way to extend the default theme functions is to place if(!function_exists('function-name')) { in the main theme_functions.php and then add my function in the child.
It would be great if this could be already in place by default
Is this correct or is there another way to do what i need to do?
Comments
please take a look at another topic where we explained how it exactly works http://forum.muffingroup.com/betheme/discussion/3128/theme-shortcodes-php-doesn-t-work-in-betheme-child
Also please take a look at https://codex.wordpress.org/Child_Themes where all information about child theme are.
Thanks!
Hi,
what I wrote to you is from the page you suggested me to take a look at https://codex.wordpress.org/Child_Themes
And that is:
TIP FOR THEME DEVELOPERS. The fact that a child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable —that is, replaceable by a child theme— by declaring them conditionally. E.g.:
if ( ! function_exists( 'theme_special_nav' ) ) {
function theme_special_nav() {
// Do something.
}
}
In that way, a child theme can replace a PHP function of the parent by simply declaring it beforehand.
Thanks for understanding!