How to create a Child Theme for WordPress

Probably sometimes you have secured (of the way that is) a group for WordPress that included a secondary subject and you did not know what was. Generally child usually has a similar name with the completion œ- added, it sounds to you? He is frequent not to pay much attention to him. You do not worry, as of today you will know what is, why is used and why the use of Child Themes for Wordpress is recommendable.

We begin, what is a Child Theme?

Briefly, it is an extension of the group father (Parent Theme) that we will use to make modifications without this affects in the future to possible updates of the original group. I put an example to you:

Sup³n that you install a group in your WordPress and want to adapt it to a somewhat different image, in addition to making some changes in the code. The normal thing is to investigate between so many archives and to make the pertinent changes to secure the results that we want: changes in the style, modification of some function, etc. But, what happens if at some future date this group receives an update? What will happen, if you update, is that you will lose all the changes that at the time you did, since the archives of warm up to you will be crushed and your work will have been in vain.

I suppose that already you will become an idea as why they serve to the Subjects Son. It is not more than a group where you will realise the changes that you wish on the subject father. This child theme inherits so much the design as the functionality of his parent theme, reason why we will be able to replace the code simply writing one new one in this group, or adding modifications the already existing one. To create a subject son is very simple.

How I create a Child Theme?

You technically only need to keep to end two step to create a subject son:

  1. To create a folder in the directory wp-content/themes giving the name him that you love to your subject son (for example: tubular powder-child, if the subject father were called œTubular powder)
  2. To include a file style.css in the created directory. It is the only required file and it must include the following code:
/* Theme Yam: Macaroni Child Theme URI: https://ejemplo.com/macarron-child/ Description: Child Theme for the group Author Macaroni: Wewokc Author URI: https://www.wewokc.net Warms up to you: tubular powder Version: 1.0.0 Tags: etiqueta1, etiqueta2, etiqueta3¦ * @import URL (œ. /macarron/style.css); //We concerned the style sheet of the subject father

And what means all this code? Good, the name really only has importance that you assign to him to Warms up to you, since it will have to be the name of the folder that contains your parent theme, the rest fills up fitting it you to your case.

The last line is used to concern the style sheet of parent theme, nevertheless exists a more correct way to do it through wp_enqueue_style, although you will need another called file functions.php with the following code. He is vital that you are become familiar with the file functions.php!

<? php add_action (˜wp_enqueue_scripts™, ˜theme_enqueue_styles™);
function theme_enqueue_styles () \ {wp_enqueue_style (˜parent-style™, get_template_directory_uri (). ˜/style.css™);}? >

Now you have child theme with two fundamental archives: functions.php and style.css. We already can modify the subject without fear to lose it in the future, but before we must activate it. As if another group one was, entering the menu Appearance Subjects, we will find our new Child ready Theme to activate.

Changing the style of a class by means of the Child Theme

So that it is easier to understand it, we go with a practical example of how changing to the aspect of our group with some simple lines of css. It is very simple, but it will serve so that it is understood, in the image you can see the change that we are going to take to end.We will modify the color of the headed H3 and we will add a underlining to him; on the other hand, we will change background of the outstanding message and the thickness of the left edge. It will be enough with adding to the following code to ours style.css of the subject son.

h3 \ {text-decoration: underline;
color: #44AAFF;} div.alert-box \ {background-color: #E9FDEE;
border-left: 1px solid green;}

That easy we changed the style, but we can far go much more with the use of filters and other very useful methods. Now that you know what is and why we must use Child Themes you intention to that you try to make some modification by your account.

If you have found useful this entrance, or you have any type of doubt, you do not doubt in leaving a commentary. You do not lose the next entrances on WordPress!

Commentaries

  • Edu it says:

    Carlos I have a pair of referring doubts to child themes.

    How I can establish an image for child theme that visualizes in the section to choose theme?

    Aside from functions.php I can create comments.php, footer.php and others? Or it isn't good for having so many? ¦

    Carlos thanks 🙂

    • Wewokc he says:

      Hey Edu,

      You only must create an image that is called screenshot.png within the folder of child theme with a size of 880x660px.

      On the archives, you can and you must create those that you say, I never touch Core of WordPress. He is indistinct those that you have in child, since it will always give preference them them. For some changes equal the use of hooks is more recommendable, soon I will try to make a guide on action and filters.

      A greeting!

  • Analia it says:

    Thanks! Excellent explained. Greetings.

  • Brenda Meneses he says:

    Hello Carlos

    I am new in this world of wordpress, at the moment I am in a new use and they have their present page in wordpress (latinosiae.com), but estan making a change name brand and want re to design the website, that implies to create a group from zero for wordpress, because they want it totally customized by where I begin? that is to say, after which the designer me pass the design what is first that I must do. In addition while the new page is implemented, company wants to implement form of contact totally customized and that furthermore sends all the information in format pdf after that it is completed,how podria to do that without affecting what already this? ¦ I am scared¦

It lets a commentary

To subscribe to me!

No, thanks.