Title: Adding a function to a child theme&#039;s functions.php file
Last modified: August 21, 2016

---

# Adding a function to a child theme's functions.php file

 *  [hunter44](https://wordpress.org/support/users/hunter44/)
 * (@hunter44)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/adding-a-function-to-a-child-themes-functionsphp-file/)
 * I have a simple newbie question:
 * I am using the Twenty Eleven theme and want to add a function to my child theme’s
   functions.php file.
 * Right now, my child functions.php file has only the following lines in it:
 *     ```
       <?php
       /*
       adding second & third nav to child theme
       */
        register_nav_menus( array(
        'primary' => __( 'Primary Menu', 'twentyeleven-child' ),
        'secondary' => __( 'Secondary Menu', 'twentyeleven-child'),
        'third' => __( 'Third Menu', 'twentyeleven-child'),
        ) );
       ?>
       ```
   
 * I want to add a function to this child functions.php file that will be a modification
   to the function “twenty eleven_posted_on()” that appears in the main (parent)
   functions.php file.
 * What I want to know is simply this: do I add the modified function right below
   the code I have in functions.php already?
 * In other words, can I simply add the code:
 *     ```
       function twentyeleven_posted_on() {
       …modified function code goes here...
       );
       ```
   
 * Thank you.
 * My site: [http://roadslesstraveled.us](http://roadslesstraveled.us)

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

 *  [pinokio](https://wordpress.org/support/users/lapanwebsite/)
 * (@lapanwebsite)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/adding-a-function-to-a-child-themes-functionsphp-file/#post-4437224)
 * You can not have two same functions.
    If you think to add `twentyeleven_posted_on()`
   to child functions.php, you will have to delete it in parents functions.php
 * Create function with different name, and in template where you call `twentyeleven_posted_on()`,
   call the new one like: `twentyeleven_child_posted_on()`
 *  Thread Starter [hunter44](https://wordpress.org/support/users/hunter44/)
 * (@hunter44)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/adding-a-function-to-a-child-themes-functionsphp-file/#post-4437262)
 * Thank you LapanWebsite.
 * So are you saying that if I need to modify one of the theme’s functions so that
   whenever it is called (and I don’t know when or where it is called), the best
   way to do it is in the theme itself rather than in a child theme??
 *  [pinokio](https://wordpress.org/support/users/lapanwebsite/)
 * (@lapanwebsite)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/adding-a-function-to-a-child-themes-functionsphp-file/#post-4437270)
 * Best way is to create new function, than if it is used, for example in single.
   php, than you copy single.php from parent theme to child, and open that child
   single.php which you copied, and you change:
    `<?php twentyeleven_posted_on();?
   >` With new one you made in childs functions.php: `<?php twentyeleven_child_posted_on();?
   >`
 * This is just an example to direct you, I did not worked with that theme ever,
   so I don’t know its functions.
 * You can do it in parent theme also, than you do not have to change template code,
   but it is not recommended here to change parent themes, and also, every new theme
   update will delete/reset your code.
 * Hope that helps.

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

The topic ‘Adding a function to a child theme's functions.php file’ is closed to
new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [pinokio](https://wordpress.org/support/users/lapanwebsite/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/adding-a-function-to-a-child-themes-functionsphp-file/#post-4437270)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
