Title: Child and parent function execution issue
Last modified: August 22, 2016

---

# Child and parent function execution issue

 *  Resolved [pro100tom](https://wordpress.org/support/users/pro100tom/)
 * (@pro100tom)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/child-and-parent-function-execution-issue/)
 * Hi, friends. I have recently started to learn WordPress. In [this](http://codex.wordpress.org/Child_Themes)
   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?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [jherrington1](https://wordpress.org/support/users/jherrington1/)
 * (@jherrington1)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/child-and-parent-function-execution-issue/#post-5391222)
 * I’m not sure why you would be using ! function_exists inside a child theme unless
   you have a very unusual circumstance. Basically you have the right understanding.
   This statement is used in parent themes so that it is easy for child themes to
   create their own definitions for these themes. Essentially you could copy the
   function from the parent them, bring it into your child theme, and then edit 
   it. If they didn’t have this in the parent theme, then if you called it in the
   child theme it would break the site as it would be a fatal error. Does that make
   sense?
 *  Thread Starter [pro100tom](https://wordpress.org/support/users/pro100tom/)
 * (@pro100tom)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/child-and-parent-function-execution-issue/#post-5391258)
 * It makes perfect sense, thank you! Probably I misunderstood that topic a bit 
   or it is just written in a bit unclear way. Anyways I am very thankful for your
   respond and have no questions regarding this topic anymore.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Child and parent function execution issue’ is closed to new replies.

## Tags

 * [child](https://wordpress.org/support/topic-tag/child/)
 * [code](https://wordpress.org/support/topic-tag/code/)
 * [conditional statement](https://wordpress.org/support/topic-tag/conditional-statement/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [parent](https://wordpress.org/support/topic-tag/parent/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [programming](https://wordpress.org/support/topic-tag/programming/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [pro100tom](https://wordpress.org/support/users/pro100tom/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/child-and-parent-function-execution-issue/#post-5391258)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
