Title: Function.php and a child theme
Last modified: August 20, 2016

---

# Function.php and a child theme

 *  [JoAnn22](https://wordpress.org/support/users/joann22/)
 * (@joann22)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/)
 * I have created a simple child theme of Twenty Eleven. I wanted to change some
   things in the style.css file and read it’s better to start a child theme so I
   always have the original theme when I need it, which I agree. I also wanted to
   edit the function.php so I can add some of my own photos to be used in the header
   when random pictures is used. Plus add a favicon eventually. My problem is I 
   can not find any help on how to add a function.php to a child theme. I want my
   theme to use the Twenty Eleven function.php all the time, except for the few 
   additions I might make. How do I do that? Do I have to ‘import’ function.php 
   in like I did with style.css? Can I just copy the whole function.php file and
   use and edit that one instead? What would be the best way to go about using the
   Twenty Twelve function.php with just some changes and additions I’ve made without
   changing the original file?

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

 *  [peredur](https://wordpress.org/support/users/peredur/)
 * (@peredur)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338056)
 * I’m not sure why you want to use functions.php (note that it’s plural, BTW) for
   the issue you have, but I guess you know what you’re doing…
 * Well done for creating a child theme.
 * First, you add a functions.php file to a child theme by simply creating a file
   called `functions.php` in your child theme’s folder. That’s it.
 * Now, unlike any other files you put in your child theme, your child theme’s version
   of functions.php gets loaded *before* the equivalent file in the parent. That’s
   why it’s important to make sure before you go creating a function of the same
   name that you check that your parent theme’s equivalent function is surrounded
   with:
 * `if ( ! function_exists( 'function_name' ) ) :`
 * In the case of twentyeleven it almost certainly is as it’s a child-theme-friendly
   theme.
 * The upshot of all this is that your child theme’s version of any functions gets
   loaded first and so the (wrapped) parent theme’s version is ignored.
 * And that’s it!
 * HTH
 * PAE
 *  [peredur](https://wordpress.org/support/users/peredur/)
 * (@peredur)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338058)
 * Here’s how to [add a favicon](http://codex.wordpress.org/Creating_a_Favicon),
   BTW
 * PAE
 *  [jase78](https://wordpress.org/support/users/jase78/)
 * (@jase78)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338092)
 * Peredur, I notice you have helped a lot of people on here.
 * Just wondering if you can help me with something. I see everyone talking about
   files and there being content in them, can you explain in the simplest of terms
   where they are???
 * Thanks heaps, and sorry for hijacking ur post JoAnn22
 *  Thread Starter [JoAnn22](https://wordpress.org/support/users/joann22/)
 * (@joann22)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338095)
 * Peredur, so you don’t think I should use the functions.php file to add additional
   header photos and a favicon? I know how to add those things to the original functions.
   php file, but I didn’t think I should be editing the original file. So I’m trying
   to figure out how to make my own functions.php file for the additions I want 
   to make instead of editing the original file. Do you think I should just edit
   the original file? I guess I don’t know how to do what I want to do without using
   the functions.php file. Is there another way?
 *  [peredur](https://wordpress.org/support/users/peredur/)
 * (@peredur)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338101)
 * Well, you certainly don’t need to alter your functions.php file to add a favicon,
   as the link in my previous post shows.
 * For your other problem (the images), you might put a function in functions.php,
   I guess.
 * As to how to make your own functions.php file, I thought I’d explained that. 
   Is there something in my earlier post (last-but-one) that you don’t understand?
 * Perhaps I should have made at least one thing clearer. WordPress loads your functions.
   php file, from your child theme directory, first and then it loads the parent
   theme’s functions.php file. So you don’t have to copy the parent functions.php
   file.
 * Cheers
 * PAE
 *  [peredur](https://wordpress.org/support/users/peredur/)
 * (@peredur)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338102)
 * Just a thought. On the business with the images have you tried uploading an image
   from your Dashboard –> Appearance –> Header page?
 * I’m just wondering if that image then gets added to those supplied by default:
   and if it does, whether it gets added to the list of those that will be shown
   at random if you check the random check box.
 * Just a thought.
 * Cheers
 * PAE
 *  Thread Starter [JoAnn22](https://wordpress.org/support/users/joann22/)
 * (@joann22)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338104)
 * Ok, I understand about the favicon, thanks for the very informative link. I do
   understand what you said about the functions.php I don’t think I’m explaining
   my question enough. I guess I’m just trying to figure out if I can make my own
   functions.php and add bits and pieces in it to change or update my theme in the
   same way I do with the style.css file. For an example, with the random photos
   used for the header. Can I make my own functions.php file copying the snip-it
   of coding from Twenty Eleven’s original functions.php file and change it to pick
   my own photos? And that be the only coding in my functions.php and that way I’m
   not editing the original functions.php. Or do I have to create a fully complete
   and extensive functions.php like the original? Does that make sense? If not, 
   I guess I’ll just keep playing until I figure it out. 🙂
 * And no, to add my image in the list of random images I need to add it to the 
   array in the functions.php file. Like I said, just trying to figure out if I 
   can do that without editing the original file. Thanks for all your help. Even
   though I’m probably not making much sense. 🙂
 *  [peredur](https://wordpress.org/support/users/peredur/)
 * (@peredur)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338107)
 * Hi JoAnn22,
 * I’m clearly not being clear.
 * To have your own functions.php file just create one in your child theme directory.
 * What you put in it is up to you. You can leave it empty if you want.
 * Whether you use an existing function from your parent theme as a template for
   a new function of your own creation or not, is up to you. Whether you overwrite
   a function in your parent or write a function with a completely new name, is 
   up to you.
 * But as far as I can tell, you don’t need to mess with a functions.php file to
   do what you’re trying to do. I just looked at the code in the existing functions.
   php for the twentyeleven theme and believe from what I see that the random images
   will be taken from those registered with the theme. I’m also assuming that uploading
   an image of your own from Dashboard –> Appearance –> Header will register that
   image. So it will automatically (I think) get included in the images to be picked
   from. If I’m wrong about this, I’ve no doubt someone else will chip in and say
   so.
 * And if that doesn’t work, I’d try uploading an image (of the right size, of course)
   to wp-content/themes/twentyeleven/images/headers/ and see what happens.
 * There doesn’t seem any point in writing new PHP code if the existing code will
   do it for you.
 * Cheers
 * PAE
 *  Thread Starter [JoAnn22](https://wordpress.org/support/users/joann22/)
 * (@joann22)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338111)
 * PAE OK I now understand what you are saying, and you did answer my question, 
   thank you! And I have looked, and though I’m not an expert, it doesn’t seem like
   just uploading a header will include it in the random headers like I want. But
   I do know the coding to do that, I just didn’t know if I could do partial coding
   in my own functions.php, which you answered. Thank you for sticking with me on
   this, it has really been a HUGE help. 🙂
 *  [peredur](https://wordpress.org/support/users/peredur/)
 * (@peredur)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338114)
 * Yes. You’re right about the need for a bit of coding to do it. I just tried it
   out on my local test site.
 * In case you hadn’t seen it, here’s some instructions on how to do it:
 * [http://voodoopress.com/2011/07/adding-and-removing-default-headers-in-twentyeleven/](http://voodoopress.com/2011/07/adding-and-removing-default-headers-in-twentyeleven/)
 * Cheers (and thanks for teaching me something)
 * PAE
 *  Thread Starter [JoAnn22](https://wordpress.org/support/users/joann22/)
 * (@joann22)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338115)
 * Excellent, those instructions look great. Thank you so much for your help.
 *  [peredur](https://wordpress.org/support/users/peredur/)
 * (@peredur)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338116)
 * De nada. And happy blogging!
 * Cheers
 * PAE

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

The topic ‘Function.php and a child theme’ is closed to new replies.

 * 12 replies
 * 3 participants
 * Last reply from: [peredur](https://wordpress.org/support/users/peredur/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/functionphp-and-a-child-theme/#post-2338116)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
