WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Started with Child Theme (6 posts)

  1. Fredber
    Member
    Posted 2 years ago #

    Created a Child Theme so I wont have to edit my parent theme's files.
    (starting over again since I did that on my first try)

    Should I create substitutes for all the files, or just the ones I need at the moment?
    Are ALL changes now made in the child theme, will I never have to edit the parent theme?
    Do I need to include some code that refers back to the parent theme if I add some changes into the child theme?

  2. Should I create substitutes for all the files, or just the ones I need at the moment?

    Start with just the ones you need at the moment. If you duplicate all the files, why make it a child theme?

    Do I need to include some code that refers back to the parent theme if I add some changes into the child theme?

    Just make the child theme's style.css refer to the parent template theme for now. For example, looking at this from http://codex.wordpress.org/Child_Themes#The_required_style.css_file

    /*
    Theme Name:     Twenty Ten Child
    Theme URI:      http: //example.com/
    Description:    Child theme for the Twenty Ten theme
    Author:         Your name here
    Author URI:     http: //example.com/about/
    Template:       twentyten
    Version:        0.1.0
    */

    That in it's own directory will get you started with a child theme of Twenty Ten. Replace the Template: portion with the theme you actually want to use.

    That will get you started. When you want to modify a php file from the parent theme, put that modified copy into your child theme directory. No need to copy the files you have not modified.

  3. Fredber
    Member
    Posted 2 years ago #

    Thanks.

    When you want to modify a php file from the parent theme, put that modified copy into your child theme directory. No need to copy the files you have not modified.

    But do I copy the entire file, and edit the changes I want among all the other content,
    or make a blank file with just the small changes I want? (and it finds all the other content from the file in the parent theme)

    Frederick

  4. If you wanted to modify a file in the parent directory, then make a copy of just that file into your child theme directory and modify that one file there.

    For example, if you wanted to customize a theme's single.php file, the copy that one file into your child theme directory and modify the copy. You'd make a complete copy of that single.php and nothing else.

    The child theme would use your single.php and get everything else from the parent.

  5. Fredber
    Member
    Posted 2 years ago #

    Okey, so when I put a style.php file in my child theme, WP no longer looks for data in my parent theme's style.php file?

    My orginal question was wether I could have some data in my Child style.php file, and some data in my Parent style.php file, and they somehow worked together.

    Frederick

  6. I see what I did wrong, I left out the import. The child theme style.css should also include an @import too.

    /*
    Theme Name:     Twenty Ten Child
    Theme URI:      http: //example.com/
    Description:    Child theme for the Twenty Ten theme
    Author:         Your name here
    Author URI:     http: //example.com/about/
    Template:       twentyten
    Version:        0.1.0
    */
    
    @import url("../twentyten/style.css");

    See the @import portion? That will include all of the style CSS info from the parent. Any CSS you include in your child style.css will override the parent theme CSS.

    In one of my child themes for TwentyTen I added these lines after the @import (I forgot why I did):

    #wrapper {
            margin-top: 20px;
            background: #fff;
            padding: 0 20px;
            /* this?: */
            border-radius: 10px;
            -webkit-border-radius: 10px;
            -moz-border-radius: 10px;
    }

    That will contain the portions of CSS that I like and override the parent theme CSS for just those portions.

    All the data will come from the parent theme unless there is a file with the file name in the child directory. So if you replace just single.php only as above, all the .php files will come from the parent except that one single.php file.

    Edit:

    But do I copy the entire file

    Yes, copy the entire file.

Topic Closed

This topic has been closed to new replies.

About this Topic