Updating code in child theme

I am using theme twenty fifteen. I also created a child theme. I was being told from your staff that since I have a child theme it is safe to continuous to upload code into the CSS of the parent them. Now I got another instruction from a different staff that said I should do all my update in my child theme. I am confuse who is right.

So to be safe, should I copy all my coding from CSS of the parent theme to the Style.css of the child theme and then delete all the code in the CSS of the parent theme? And moving forward i will have to load all new codes into the style.css of the parent theme right?

Thanks for the clarification.
Chad

  • Dimitris

    So to be safe, should I copy all my coding from CSS of the parent theme to the Style.css of the child theme and then delete all the code in the CSS of the parent theme?

    Parent theme should stay intact, no change at all should be made in its files, not even in its styles in style.css file.

    And moving forward i will have to load all new codes into the style.css of the parent theme right?

    All of your custom CSS code should be placed in your child theme's style.css file.
    This file will override the style.css file of your parent theme. To make sure we load the parent file’s stylesheet we will need to enqueue it. This can be done in the theme’s functions.php file

    add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
    function enqueue_parent_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }

    Reference: https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

    Hope that was some help, feel free to post back here if more assistance is required!
    Warm regards,
    Dimitris

  • CHAD

    I copied those code provide from you into my child theme functions.php, I then refresh my website and the whole site got disable:unamused:

    So I took it off

    Basically, my question is since i have a style.css in my child them:
    1. From now on, should I insert all new css coding into my child style.css or Keep inserting in my parents Custom CSS?
    2. I currently have some Custom CSS in my parents theme (see attachment) should i leave it there as is or should I copy all those existing codes and transfer into my child style.css?

    thanks
    chad

  • Dimitris

    I copied those code provide from you into my child theme functions.php, I then refresh my website and the whole site got disable

    The snippet I provided should be in place so that style.css file of parent should be loaded.
    Main concept of child dictates that each file that's present in child theme, will override the same filename of parent theme. So as your child theme must have a style.css file in order to work, you should use the snippet I mentioned in order to enqueue the style.css from parent which is getting overridden. If parent theme doesn't use style.css for CSS rules, then it's safe to skip this part.

    1. From now on, should I insert all new css coding into my child style.css or Keep inserting in my parents Custom CSS?
    2. I currently have some Custom CSS in my parents theme (see attachment) should i leave it there as is or should I copy all those existing codes and transfer into my child style.css?

    The Custom CSS of your screenshot should be coming from a plugin and it's not style.css of your parent theme. You can either use style.css of your child theme (via some FTP connection) or this Custom CSS plugin of course (the rules you use in there will still be in place even if you change theme)

    Let me know if more assistance is required here!
    Warm regards,
    Dimitris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.