WordPress.org

Ready to get started?Download WordPress

Forums

Child Theme Questions (with premium theme) (7 posts)

  1. michelle cohen
    Member
    Posted 2 years ago #

    Hi there,
    I'm somewhat familiar with the idea behind child themes; I've read just about every recommended guide/video on the subject, and while it does seem a bit complicated (my wp development skills are of the follow directions/cut-paste variety though better than some), I think the one-click child theme plugin is a good idea for me just to set it up.

    I have some still-unanswered questions about child themes in general for my situation, hoping someone can please answer at least some:

    I am using a premium theme from Woo themes called Delicious Magazine.
    http://www.woothemes.com/2011/02/delicious-magazine/
    Here is my site (created it for my biz partner/friend):
    http://livinggreenwithbaby.com

    I do tend to make a lot of modifications to my themes (css, templates, functions.php).

    1. Regarding whether I really need to use a child theme:

    --First, my theme already includes a custom.css file, so i just add stylesheet changes there and leave the main one alone. And the functions.php file has a bit at the end that says "PUT ALL CHANGES BELOW THIS LINE"...so I feel that file's ok too...

    --WORDPRESS updgrades (and plugin updates) don't seem to really affect my site, as I"m not using a wp theme, and other than some plugin conflicts or bugs–those updates don't touch my theme, right?

    --As far as Woo's updates to the theme itself, they keep a changelog so I can just overwrite the files they've updated; they also update the framework but i dont generally edit that anyway (functions folder).

    --Also, my theme has all kinds of files that I might not know to copy over to the child theme, so it seems a child theme might be adding an additional layer of "where the F*** is that line of code" time.

    2. Now, If I DO decide to make and use a child theme (using the one click plugin), here are my questions:

    --My main question is something like: Can I sort of toggle back and forth and make changes in the parent too, (if i use one click child theme and make a child theme)? And the WORST that could happen is changes i made to the parent could get overwritten if I happen to overwrite that file when updating that file? I mean, will the changes be made to my site as I make them according to order in which they are made?

    --(this one may be a q for Woo) Which css file do i work on? I assume it would have to be the child theme one, as the custom.css file is back with the parent.

    --I don't get what the deal is with the functions.php file. Do I just copy it over to the child theme and just make changes as usual (in this case in the "add changes below this line" area? the instructions sound kind of complicated.

    --Also I assume plugins aren't affected, they just go along with the theme regardless (unless there's some conflict or bug)?

    Thank you for any advice you can provide.

    michelle

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Can I sort of toggle back and forth and make changes in the parent too

    Why on earth would you want to do that? The whole point of using a child theme is that the parent theme remain untouched.

    Which css file do i work on?

    In a child theme, you just add your changes to the child's stylesheet(s).

    Do I just copy it over to the child theme and just make changes as usual

    No. You create a fresh functions.php file in the child them and just add your new or amended functions to it.

    I assume plugins aren't affected

    Correct - unless you are using a parent them that relies upon specific plugins. In that case, check with the theme's developer first.

  3. michelle cohen
    Member
    Posted 2 years ago #

    Ok, I have some more specific questions that still aren't clear for me.

    1. Would WORDPRESS updates themelves ever overwrite anything or break my site in a normal situation?
    Especially since I'm not using a theme that comes bundled in the WP install. I've always done the updates to my sites and never had anything change. I assume WP updates don't affect the theme files. Is there something new with 3.0+ re this? Can I just assume that the only threat of overwriting theme files is if I update my theme itself or parts of it. Is this correct?

    2. Understanding child themes would be easier for me if it were just a case of making the changes that need to be made on the child theme files, which correspond to the same ones in the parent. What complicates it for me is that you not only have to make the changes in the child theme files but make them *differently*, apparently, in cases other than .css file and page template files.

    Specifically, what needs to be added to the code in the functions.php file? How do I handle that file in the child theme?

    And which other files from the parent theme have to be copied or recreated in the child theme and coded differently?

    3. Could the avoidance of overwriting be accomplished by checking the changelog after theme updates from Woothemes and just updating piecemeal based on the changelog files? Theme updates don't tend to be too frequent nor sweeping, in my experience...What is the downside of this method?

    Thanks for any answers you can provide on this!

    Michelle

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    1. Possibly. For example, the version of jQuery bundled with WordPress has changed a few time recently. If your theme relied upon a specific version of jQuery and that version was no longer available in WordPress, your theme would suffer as a result.

    2. I'm not sure that you mean by "differently". The functions.php file in a child theme should start off empty and should only be populated by completely new or amended parent functions.

    3. Not all theme developers maintain changelogs. even where they do exist, it's unwise to rely on them completely. Even the best dev can forget to enter something in a changelog.

  5. michelle cohen
    Member
    Posted 2 years ago #

    This, below, is the part I was referring to re #2. Maybe don't need to worry since i'm not a theme developer and it's just suggesting how to incude extra functionality if I wanted to?
    //

    TIP FOR THEME DEVELOPERS. The fact that a child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable —that is, replaceable by a child theme— by declaring them conditionally. E.g.:

    if (!function_exists('theme_special_nav')) {
    function theme_special_nav() {
    // Do something.
    }
    }
    In that way, a child theme can replace a PHP function of the parent by simply declaring it again.

    Referencing / Including Files in Your Child Theme

    When you need to include files that reside within your child theme's directory structure, you will use get_stylesheet_directory(). Because the parent template's style.css is replaced by your child theme's style.css, and your style.css resides in the root of your child theme's subdirectory, get_stylesheet_directory() points to your child theme's directory (not the parent theme's directory).

    Here's an example, using require_once, that shows how you can use get_stylesheet_directory when referencing a file stored within your child theme's directory structure.

    require_once( get_stylesheet_directory(). '/my_included_file.php' );

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Unless you need to amend functions in the parent theme, then it's not something you need to worry about. If you do, then it's likely you'll have to approach it on a case-by-case basis as not all themes as totally child-friendly in this regard.

  7. morphosic
    Member
    Posted 2 years ago #

    michelle, you might already have this straight, but in case you don't...

    a child theme starts with nothing but the style.css file. in that file you reference the parent theme. and likely reference the parent theme's style.css file. it should look something like this:

    /*
    Theme Name: [Themename] Child
    Theme URI: http://yoursite.com
    Author: you
    Author URI: http://yoursite.com/
    Version: 0.1
    Template: [themename]
    */
    
    @import url("../[themename]/style.css");

    in so doing, the child them will reference absolutely everything from the parent theme. you DO NOT need to copy everything over from the parent theme's folder. that's why your functions file starts "blank", because the child theme will automatically load the parent theme's functions file as well. it will use all of their template's as well. if you want to make a change to page.php, then make a copy of it in your theme folder and edit it. wp will then load your page.php file instead of the parent theme's file.

    with it set up like this, your parent theme can be updated and you won't have to worry about a thing, because your child theme will still be loading all of the parent's stuff.

    did that make sense?

Topic Closed

This topic has been closed to new replies.

About this Topic