Removing / Customising CSS and Functions Best Practices

Community Forums Forums Design Tips and Tricks Removing / Customising CSS and Functions Best Practices

This topic is: not resolved

This topic contains 4 replies, has 3 voices, and was last updated by  David Chu 5 months, 3 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #103066

    emmaholmes
    Member
    Post count: 3

    Hey folks.

    Can anyone advise me on how best to modify a child theme safely so that if there is an update to a child theme, it is easy to keep any customisations made?

    I know how to add a custom CSS file and add a custom functions file, but what happens if you want to delete something in the original functions.php file or style.css file?

    Would really appreciate your input. I’m not a developer or coder, I have a basic understanding and knowledge.

    Thanks!

    Emma

    • This topic was modified 5 months, 3 weeks ago by  emmaholmes.
    • This topic was modified 5 months, 3 weeks ago by  emmaholmes.
    #103081

    David Chu
    Participant
    Post count: 1373

    Emma,
    Interesting question. By knowing what you know, you’re way ahead of most people, and I applaud your willingness to learn! It’s tough to give “best practices” for WordPress – there are so many ways to do things. And I know of no magic perfectly clean fix.

    If it were me, if I found something I didn’t want in the original files, I might comment them out with an explanation. Then I would back up that file. The comment makes it easier to see and remember why. Then when the child theme update comes along, I’d either manually get my changes back in, or use a file compare program to find the changes and put my stuff back in if there were a lot of them.

    Sometimes you can “finesse” removing something. Say you have this in the original….
    add_theme_support( 'genesis-responsive-viewport' );

    … you could put this in your custom functions file:
    remove_theme_support( 'genesis-responsive-viewport' );

    Same deal with add_action, remove_action. But that seems inefficient to me, and many things you might find in a function file may not work that way.

    I hope that helps a bit,
    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #103105

    braddalton
    Participant
    Post count: 10245

    You can copy the CSS code to the end of the style.css file and make changes there or simply modify the default code and add a comment so you know its been changed.

    Child themes aren’t generally updated.

    You can also add or remove functions from your child themes functions files.

    When adding new functions, its generally best to add them at the end of the file.

    Always tale a full backup of your child themes before making any modifications.


    #103132

    emmaholmes
    Member
    Post count: 3

    Hey David, thanks so much. I started to do that today, so good to know I’m on the right track(ish)!

    Hey Brad, thanks too! That makes sense.

    Really impressed by the speed and helpfulness of the answers guys, I really appreciate it!

    THANKS!!!!!

    #103185

    David Chu
    Participant
    Post count: 1373

    Emma,
    Glad to hear it!
    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.