Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17436

    Hi, with other theme developers, the child theme functions.php seems to have a lot of code, followed by a specific area where I can add my changes/additions. What do I need in a child theme functions.php for Propulsion so it will work?

    Thanks, Sandie

    #95464

    Hi,

    To create a child theme, only a new directory with a css file which has (a) Template directive (b) @import directive are required. All else is optional. Other theme authors create child theme files and stuff them with all sorts of fluff.

    Mainly it’s done to force you into using the child theme, since some of the framework function calls of the parent theme are hardcoded in the child theme . Also it is done to relax the first time WordPress admin, and make them a little more comfortable using the child functions.php file (a file which is not required). It’s not easy to start writing php code for the first time looking at a completely empty functions.php file, so some developers add a few things in there.

    On that note this is what you should do:

    1) Create a folder right next to the parent folder, located in your ‘/wp-content/themes/’ directory. You can call your child theme folder anything you want , however to make life simpler if you have many themes, its a good idea to call it by the same name as the parent *with a dash and the word child at the end*. So in your case the parent folder is ‘/wp-content/themes/propulsion’ and child folder would be ‘/wp-content/themes/propulsion-child’ (though again you can call it whatever you want.)

    2) Inside your new empty child folder, create a style.css file, and add the following into it

    /*
    Theme Name: Any Name You Want
    Description: Anything
    Author: Anything
    Template: propulsion
    */

    @import url("../propulsion/style.css");

    /* write custom css below */

    So as you can see, the most important thing is to have Template directive, and write the name of the parent folder exactly how it is, so if your parent folder is called PRopulSION , you would write Template: PRopulSION.

    The next part is to have the @import statement exactly as above, making sure that it has the name of the theme folder exactly as your parent folder is written (capitalization, etc.)

    Now if you want you can create a functions.php file and drop it in the child theme folder, and you can even add the following into it though its not necessary

    <?php

    /* custom PHP functions below this line */

    ?>

    If you want to modify a file, you would go into your parent theme folder, copy the file, then go into your child theme and paste it there *into the same folder structure matching the parent theme.* Since the child theme has no folders inside, you would have to create empty folders matching the location where you copied the file you plan on editing.

    So if you want to edit file /parent-them/folder1/js/folder3/some-file.php , you would copy some-file.php and create empty folders in your child theme so that /child-them/folder1/js/folder3/ exists and thats where you would paste some-file.php which will now override its counterpart in the parent theme.

    Don’t add anything more to styles.css file in the parent or child theme. Instead create a folder in your child theme called ‘css’ and place an empty file inside called custom.css (that matches the location of custom.css in your parent theme.) Add your css in there or in Quick CSS in the backend.

    I hope this helped you out,

    Thanks,

    Nick

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘What do I need in my child theme functions.php file for it to work properly ?’ is closed to new replies.