• thomasmpreston

    (@thomasmpreston)


    Hi. I’m fairly new to wordpress, and while I have a few basic sites up and running I need some help going a bit further.

    I’ve read about child themes and tried to search around the forums a bit but still a little stuck. Basically,. I’m not 100% clear on the best way to use them, and until I can get to the point where I can build my own theme I think I need to in order to have the kind of customisation I want.

    So, here’s where I am. I have tried using a one-click child theme plugin which basically just copied the css file over for modification. All well and good but I want to go tweaking the templates etc on my themes and not lose that when it updates.

    The other approach I’ve tried is make a clone of the entire theme and call it ‘XXX – child’ in my site content folder then go from there.

    However on one of these posts I read that you shouldn’t copy the functinos.php file and I got a bit worried that this isn’t the best way to do it. Are there any other files I should be leaving alone? And what if I modify some templates in my child theme folders then the main theme updates, will that cause problems? Maybe it’s a basic question I don’t know, I’m just a little confused at the moment! I can post examples of what I’m trying to do if it’s not clear, but in the mean time, anyone have any clear dos and don’ts for using child themes? Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    The other approach I’ve tried is make a clone of the entire theme and call it ‘XXX – child’ in my site content folder then go from there.

    Don’t do that. ??

    That’s not a child theme when you do that. It’s not necessarily a bad thing but you usually end up creating more work for yourself that way.

    Child themes (once you get them) are the easiest thing to do. The starting point is just 2 files.

    my-child-theme/style.css

    /*
    Theme Name: Some Theme's Child Theme
    Author: Self-Help WordPress User
    Template: theme-directory-name-here
    */
    
    @import url("../theme-directory-name-here/style.css");

    And a one line my-child-theme/functions.php like so

    <?php

    Which is just a place holder for any future additions. The child theme’s functions.php file is never a copy of the parent theme’s functions.php file.

    Those 2 files are your starting point and depending on your parent theme and what you want to change you then proceed from there.

    Which theme are you starting with? Almost all of the themes in the WordPress repo here can be child theme’ed.

    Thread Starter thomasmpreston

    (@thomasmpreston)

    Thanks for the reply ??

    Ok, I’m obviously thinking this all wrong. My current project uses Responsive theme. As an example, I want my standard pages here to be pretty much like the ‘Full width page (no sidebar)’ template except I don’t want comments. So my inclination is to go to the full-width-page.php file and remove the comments code.

    Are you saying I need to add this as a new page type in that second file? I guess my thinking was to just use what’s there and tweak it to be how I wanted it rather than start with a new file, what’s the problem with doing that?

    leejosepho

    (@leejosepho)

    I guess my thinking was to just use what’s there and tweak it to be how I wanted it rather than start with a new file…

    Some files get copied into the Child Theme, then modified. But in a case like not having comments, there are some Dashboard settings for controlling certain things. In my own case, and since I am not a coder, I began learning about WordPress settings and theme-specific changes by doing a *lot* of “How to…?” searches both here in these forums and out on the ‘net.

    WPyogi

    (@wpyogi)

    just use what’s there and tweak it to be how I wanted it rather than start with a new file, what’s the problem with doing that?

    The problem with modifying theme files directly is that they will be overwritten when the theme is updated – so you will lose all your changes (you really don’t want to go there ?? ). And you also don’t want to avoid updating because eventually (or sooner) you will very likely run into security and/or compatibility issues.

    A Child Theme lets you make changes that won’t be lost upon updating the theme.

    Thread Starter thomasmpreston

    (@thomasmpreston)

    The problem with modifying theme files directly is that they will be overwritten when the theme is updated – so you will lose all your changes

    I mean a copy of the file in the child theme folder, is there a problem with (in the example above) copying the page template into my child theme, and modifying it to get rid of the comments functionality, then using that?

    Some files get copied into the Child Theme, then modified. But in a case like not having comments, there are some Dashboard settings for controlling certain things.

    It’s probably not the best example but something I was looking at at the time ?? I’m not sure there are settings in this theme to disable them but in any case, there are modifications I want to make generally.

    From your comment I assume what I’m doing IS ok? Creating a copy of the files and altering as I need?

    In my own case, and since I am not a coder, I began learning about WordPress settings and theme-specific changes by doing a *lot* of “How to…?” searches both here in these forums and out on the ‘net.

    I’ve done that too but still confused, even the comments here so far have confused me! But thanks, I’m hoping to get it eventually…

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I mean a copy of the file in the child theme folder, is there a problem with (in the example above) copying the page template into my child theme, and modifying it to get rid of the comments functionality, then using that?

    No, that is a correct procedure in a Child Theme.

    Thread Starter thomasmpreston

    (@thomasmpreston)

    I mean a copy of the file in the child theme folder, is there a problem with (in the example above) copying the page template into my child theme, and modifying it to get rid of the comments functionality, then using that?

    No, that is a correct procedure in a Child Theme.

    Ah right, ok. So I’m doing things the right way? Cloning the files I want to alter and altering them in the child theme folder? Just to be clear, I’m still very new to WordPress ??

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It depends which files you’re cloning.

    Thread Starter thomasmpreston

    (@thomasmpreston)

    It depends which files you’re cloning.

    Thanks. Which files shouldn’t I clone? functions.php I guess from the first comment. Are there any others I can’t modify?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    style.css is another – I think thats it

    howarddrive

    (@howarddrive)

    WP have other css then style css

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The files in WordPress (the core application) should never be edited or modified.

    Your theme can have other CSS than style.css, correct.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Child theme dos and don'ts’ is closed to new replies.