• I recently learned about the child theme and parent theme but i learned it after i had completely customized/modified my theme on the parent theme.

    I have installed the child theme.

    Now my question is,
    Can i move over the modifications to the child theme through SFTP?
    If so, what files am i moving over?

    I need to do this soon since my theme needs updates.

    Thank you WP community!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Reading from the Child Themes Codex, we get this information:

    […] your child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads. For instance, if you want to change the PHP code for the site header, you can include a header.php in your child theme’s directory, and that file will be used instead of the parent theme’s header.php.

    Extra care must be taken when modifying functions.php file. If you create a new functions.php in your Child Theme’s directory, it won’t override the functions.php from the Parent Theme, but loads in addition to it — and that’s a good thing. Child Theme’s functions.php is loaded before Parent Theme’s functions.php so you even can override functions in the Parent Theme’s functions.php. However, functions located in that file must be firstly prepared to be overridden by a function with the same name from Child Theme’s functions.php.

    It is usually done by wrapping the function in an if clause such as:

    // functions.php — Parent Theme
    if ( ! function_exists( 'my_function' ) ) :
    
    function my_function() {
    }
    
    endif; // my_function

    That means that the function my_function() should only be defined if it has not been defined earlier (for example, in Child Theme’s functions.php as they are loaded before)

    Thread Starter creative2usa

    (@creative2usa)

    Thank you Rastislav Lamos!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Child Theme Troubleshooting’ is closed to new replies.