Child and parent function execution issue
-
Hi, friends. I have recently started to learn WordPress. In this thread there is a heading called “Using functions.php”. Below that heading there is a “TIP FOR THEME DEVELOPERS.” heading. It is said there that the child theme function can replace the parent one by adding a conditional statement to it:
if ( ! function_exists( 'theme_special_nav' ) ) { function theme_special_nav() { // Do something. } }My question is: if we have the same function in both child and parent php files and if we add a conditional statement into the child function to check whether it already exists (It is said that child functions run before parent ones then it definitely does not exist) then how this condition helps to skip the execution in the parent’s function? After the function was executed in the child theme, it executes in the parent one. But there is no conditional statement there, so it must be executes no matter what happens. How all this logic works?
The topic ‘Child and parent function execution issue’ is closed to new replies.