Support » Themes and Templates » Newbie child-theme question

  • A little clarification. I’m trying to make my first child-theme. It is obviously simple. So simple I don’t see one thing. In what file do you declare the name of the themes? index.php in the child theme folder…I’m a stickler for details.

Viewing 1 replies (of 1 total)
  • You only need one directory and one file to create a child theme. The folder goes directly into your themes folder and should be named for your theme (although it’ll still work even if it isn’t).

    The only file you need inside your theme’s folder is style.css.

    The style.css file should contain, as the very first lines in the files, a comment block that identifies the theme and the parent theme. Something like this:

    Theme Name:     the name of your theme
    Description:    Child theme for the Xyz theme
    Author:         your name
    Author URI:     http: //
    Template:       parentthemefoldername
    Version:        0.1.0

    The only two mandatory lines are ‘Theme Name’ and ‘Template’ IIRC. The former is where your theme name is declared. The latter declares the parent.

    Beneath this comment block, you need to import the parent theme’s styles:

    @import url("../[parentthemefoldername]/style.css");

    That’s it. Once you’ve done that you have a child theme. It will show up in the Dashboard at Appearance –> Themes and you can activate it. It will look exactly like its parent, because you’ve not made any changes.

    To make changes to the styles, just add style rules to the child theme’s style.css file.

    To make changes to the PHP/HTML, copy the relevant file from the parent theme into the child theme’s folder and alter the content as required.

    To add new functions, create a blank functions.php file in the child theme’s folder and just add the new code you need. The child theme functions.php file is loaded before the parent theme’s functions.php.



Viewing 1 replies (of 1 total)
  • The topic ‘Newbie child-theme question’ is closed to new replies.