WordPress.org

Forums

What do I need to put in sidebar-footer.php and functions.php child folders? (2 posts)

  1. MariaMSM
    Contributor Day Volunteer
    Posted 3 years ago #

    I am new to child themes and used the one click child theme plugin, but it only gives you a stylesheet. A read a little on WordPress.org about child themes, but didn't see what I need to add to the child sidebar-footer.php or functions.php so WordPress references the folders correctly.

    Help?

    Thanks!
    I am using the TwentyEleven theme.

  2. peredur
    Member
    Posted 3 years ago #

    Never have understood why people use plugins for this. It takes about 5 minutes without one.

    All you need for a valid child theme is:

    • A directory for it in wp-content/themes
    • A style sheet called style.css
    • The mandatory comment block containing the 'Theme Name' entry and the 'Template' entry (see below) in style.css
    • An @import statement to import the parent style sheet, in style.css (see below)

    A minimal child theme will simply have a style.css file containing the following, located in its directory:

    /*
    Theme Name: An arbitrary name for your theme
    Template: twentyeleven
    */
    
    @import url("../twentyeleven/style.css");

    Obviously the above would only be good for child themes of the twentyeleven theme, so if you're creating a child of a different theme simply replace 'twentyeleven' with whatever that theme's directory is called, both in the 'Template' line and in the @import statement.

    This is all you need to create a child theme that will look exactly like its parent and behave exactly like its parent. It will appear in Dashboard --> Appearance --> Themes, and can be activated. From then on you can do all your editing from Dashboard --> Appearance --> Editor, if you want.

    WP now knows how to reference the parent theme because it has a location for the style sheet and the directory name of the parent for all other files not present in the child, such as unaltered template files.

    You can add a functions.php file to your child theme if you want to. Functions contained in that file will be loaded before any functions in the parent theme's functions.php file. This allows for functions in the parent theme to be overridden provided they (the parent's functions) test for the function's existence first.

    If you want to add any new template files, you can, and they will be loaded in place of any identically named template files in the parent. If you just want to modify a template (as opposed to creating a new one), the usual method is to copy the parent's template into the child's directory and then edit it, rather than starting from scratch.

    HTH

    PAE

Topic Closed

This topic has been closed to new replies.

About this Topic