Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a Template called D5 Design. They have an update, and I've made changes to a few of the PHP files in the Theme files. (changes to text on certain pages mostly) When I do the update, I realize now that I'm going to lose those changes.

My question is - when I create a child-theme, if I want to have those changes from the certain PHP files not get lost, how, where, in what way to put those changes in the child-theme?

Do I copy the folder into the child theme? do I copy just the code from the folder?

I'm completely at a basic mode on this and I just really need someone to explain it. Every post I've read so far, makes the assumption that one already knows how the Child-Theme works (even the Codex on Child-Themes.) I'm hoping something can help make this clear to me.

For example I changed a portion of the comments.php file so that the text for comments is no longer generic.

the code looks like this:

   $defaults = array('fields' => apply_filters('comment_form_default_fields', $fields),
             'title_reply' => __( '(You must register before you can post anything. Please read our Terms Of Service [bottom of the page]. <p> We hold true to them.) <p> <p>State Your Intention for Your Meditation <p> Then Come Back and Share Your Experience' )
);

If I want to have this change be part of the child-theme so it doesn't get lost, do I:

  1. Copy the comments.php folder to the child-theme?
  2. paste the above code into the child -theme?
  3. paste all of the code in the comment.php folder in the child-theme?
  4. so far off base, here's what you need to do...
share|improve this question
    
Possible duplicate : wordpress.stackexchange.com/q/102108/21376 See if that helps. –  s_ha_dum Jun 9 '13 at 14:18
    
Thanks, but it doesn't answer my question. Or may answer my question, but I don't understand it. I'm talking really, really basic explanation here. That post talks about function.php being a part of the child-theme. Does that mean that if I set up a child-theme as guided by the codex, that everything in the parent-theme will be in the child-theme? and does that include the changes that I've made to the comments.php file? if not, how do I put that code (above) into the child-theme? –  Christine Agro Jun 9 '13 at 17:50
add comment

1 Answer

up vote 0 down vote accepted

There are three core principles to parent/child theme logic in WordPress:

  1. functions.php files from both parent and child get executed during load, with one of child them first (this is little counter-intuitive so worth remembering).

  2. "Template directory" refers to parent theme and "stylesheet directory" refers to child theme. If no child theme is being used they are same and both refer to single current theme.

  3. Each template file is first looked for in child theme, then in parent theme. Note that this natively works for template files only and not theme files in general (such as arbitrary files with PHP code).

So for modification of template files they are typically copied over to child theme and edited there.

Modification of other files is case by case and depends on availability of hooks and how flexible parent theme is about that specific functionality.

share|improve this answer
    
Ok - @Rarst I think I have it. Let me just clarify - I will need to copy the comment.php file to the Child-Theme prior to updating the parent theme and in the future, if I want to make a change to a file, I should first copy it to the child theme and then make the changes. BUT I do not need to copy the entire contents of the theme, because loading will first look to the child theme and then the parent theme. –  Christine Agro Jun 10 '13 at 23:47
    
@ChristineAgro yep, that's about right :) –  Rarst Jun 10 '13 at 23:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.