• Ok I’ve decided to be sensible and try and learn about child themes. In the past I edited the parent stylesheet of my website and got everything looking just right. The theme has been updated once in nearly 3 years so I’m not too worried about it, I just want to make sure I do things right in future.

    I’ve just created a child theme and stylesheet. However this is based on the heavily edited parent theme.

    My question is, if I update, I’m guessing as the edits aren’t in the child theme, they’ll be lost? And if this is the case, how do I get the edits into the child theme? Should I just copy and paste the whole stylesheet in?

    Sorry I’m a novice, I want to learn how all this works but I don’t know where to start!

Viewing 6 replies - 1 through 6 (of 6 total)
  • if I update, I’m guessing as the edits aren’t in the child theme, they’ll be lost?

    Yep. That’s one of the reasons why we recommend child themes so much.

    Should I just copy and paste the whole stylesheet in?

    No. That’s a really bad idea. For one thing, it may stop you taking advantage of any CSS improvements in the parent theme.

    Th best approach would be to download a fresh copy of the original parent theme and then compare its stylesheet with a copy of the stylesheet from your edited theme. There are programs and tools that can do a lot of the comparison for you. Try looking for “free text diff tool”. This way you can port just the changes over to your new child stylesheet, install a fresh unedited copy of the parent and then activate your new child theme.

    You’re right. If the theme ever does get updated, all of the changes you made will be lost. A child theme is meant to protect your changes from any updates in the parent theme. Unfortunately, if you’ve already extensively modified the parent theme, it can be difficult to remember what changes you’ve made. If you have an original, unedited stylesheet for your theme, you could try a tool like Diff Checker to see what your changes were.

    Your child theme’s stylesheet should look like this:

    /*
    Theme Name: The Parent Theme's Child
    Template: name-of-the-parent-theme
    */
    
    @import url('../parent-theme/style.css');
    
    ...any customizations should go here...

    The theme name can be whatever you’d like, but the template line and the @import line need to reference your parent theme. See Child Themes for more information.

    Thread Starter fapp

    (@fapp)

    That’s amazing, thank you! Just found a copy of a stylesheet from around the time I started the blog, so that’s the best I’ve got. I’m hoping I was sensible enough to save a copy first ??

    My child theme starts out like you suggest (I used that same link to set it up). However is there a specific way that the changes need to be listed?

    It looks like most of the changes I made were small things like fonts and centering things.

    For example row 199 (original) read:
    button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; }

    and new reads:
    button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: right; }

    Should I copy in the whole line?

    thanks in advance!

    Thread Starter fapp

    (@fapp)

    I’ve just found this which looks quite useful for dummies like me ??

    https://thethemefoundry.com/blog/wordpress-child-theme/

    is there a specific way that the changes need to be listed?

    Not from WP’s pov, no but remember that CSS cascades. So that rules further down the file will over-write the same rules near the top of the file.

    Should I copy in the whole line?

    I would if there are a lot of changes that you need to port over. There’s no real need to drill down to very specific property changes unless you really want to at this stage.

    Thread Starter fapp

    (@fapp)

    Thanks for your help. I’ll have a play around and see what happens!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Child themes and updating’ is closed to new replies.