最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to transfer changes to a child theme?

programmeradmin0浏览0评论

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...

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 edited Jun 9, 2013 at 16:11 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Jun 9, 2013 at 14:05 Christine AgroChristine Agro 431 silver badge3 bronze badges 2
  • Possible duplicate : wordpress.stackexchange/q/102108/21376 See if that helps. – s_ha_dum Commented Jun 9, 2013 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 Commented Jun 9, 2013 at 17:50
Add a comment  | 

1 Answer 1

Reset to default 2

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 the child one first (this is a 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.

发布评论

评论列表(0)

  1. 暂无评论