• Hi all,
    I previously didn’t realize that when you update a theme, you lose any manual changes to your code. Here’s my dilemma:

    I have a currently live website and it needs to “update Atahualpa to v. 3.7.7.”. However, if I update it, I will lose my manual changes and style.

    Is there a step-by-step or guide on how to take a theme that has already been modified and turn it into a child them so I can update the “base theme” and not have anything go wrong? There were various tweaks and I don’t want to lose the site and its features, especially since its for a client.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Try asking on the theme’s dedicated forum: https://forum.bytesforall.com/

    Thread Starter brisus

    (@brisus)

    That is an option, but this is more for a general question regarding all modifications to any parent theme and how to convert it to a child theme.

    brisus,

    Do you have a list of the files you have modified in the core theme?

    Provided that you know what files you have modified, you can make a list, and copy those files into a child-theme folder (make sure to include the style.css file along with these.

    If you do not have a list of the files you have modified somewhere on hand, an alternative is finding an unmodified copy of your theme’s current version on your hard-drive, and looking at the last modified timestamp for all of the files, and comparing that with your local copy’s last modified date… Make a list of the files that do not have matching timestamps, and then copy those to a child-theme directory along with your style.css file from the parent theme. ( This is how I did it in a past project after learning what a child-theme was for the first time. )

    Next open up the child-theme’s style.css and add the template tag that points to your parent theme as directed on the Codex Child Themes page.

    Upload the child-theme and activate.

    Make a backup copy of your current parent theme!

    Finally, upgrade the theme.

    I would definitely advise you do this on a development server or test site first, that way if you miss a file, the design goofs up, or you get the WSOD, you’re not affecting the client’s live website.

    I hope this helps!

    -greg

    Thread Starter brisus

    (@brisus)

    I made the site a little while ago and I think I might’ve altered the functions.php, style.css, and maybe one or two other files. Off the top of my head, I couldn’t tell you.

    Thread Starter brisus

    (@brisus)

    Okay, I got the child theme to work with the style.css, but how can I included an altered functions.php file?

    If I copy it from the original modified theme and input them, then the system obviously loads the child, then the parent… or you get a serious error talking about redeclaring variables, which I have no clue about.

    For example, on my functions.php, I removed the “Powered by … …” and wanted to change that text in the new function. How do I go about that? I got the rest to work and switch over, but I need to overwrite the functions.php and possibly the header.php.

    Brisus, if I understand correctly the Child Themes page in the Codex (and it’s always possible that I don’t, LOL), functions.php of the child theme loads before the same file of the parent theme. So I think that means that if you have a child theme and you make changes to functions.php, those are the changes that viewers will see.

    What I did with a handful of sites I’ve done in WordPress was this:

    1. Create a separate directory within wp-content/themes for the child theme.
    2. Copy the files from the parent theme into that directory.
    3. Edit style.css and functions.php (and whatever other files) of the child theme as desired.
    4. Optional: go back to style.css, compare it to the original style.css, and remove anything that wasn’t changed. Make sure you’ve got a referrer back to the original style.css file: @import url("../parenttheme/style.css"); More on that here.

    Use a text compare like examdiff to find your changes, if you have a copy the original theme files, and create the child theme from the changes.

    Sample child themes functions.php, /* comments to help what goes where */

    <?php
    /* This Section Will Run first before the parents functions.php */
    
    add_action( 'after_setup_theme', 'post_theme_setup' );
    if ( !function_exists( 'post_theme_setup' ) ):
    function post_theme_setup() {
    	/* This Section Will Run Last after the parents funtions.php */
    
    }
    endif;

    HTH

    David

    Thread Starter brisus

    (@brisus)

    Rebecca, from what I read, the child function may load before the parent theme, but if you have the SAME functions, you’re declaring it twice adn it can crash the site. At least, when I did copy mine originally, it did not work. I am not fluent with php enough to know how to remove only one function or improve upon it much.

    Digital Raindrops,
    I am not really editing the functions much except maybe changing a word or two in a theme. If there are two functions, then it wants only one…not two.

    From what I read, the child function may load before the parent theme, but if you have the SAME functions, you’re declaring it twice and it can crash the site

    Hi brisus,
    WordPress loads in this order:
    Child Themes functions.php
    Parents Themes functions.php

    We add a function to the child theme with an ‘after_setup_theme’ hook to over-ride the parent functions.

    If a parent function is pluggable we can load the function in the child theme, once loaded the parent will not try to load the function and will not error.

    If a function is not pluggable we would have to create a new function and find where the function is called and rename the calls in our child theme.

    We can also remove filters and actions, then replace them with our own.

    I thought this would make an interesting topic for others, so I created a YouTube overview video this morning: here with examples for the twenty eleven theme, view at a larger size.

    HTH

    David

    Is there a way to make the parent theme (with all your modifications) into a stand alone theme (base theme?) which would then not be affected by the original parent theme being upgraded?

    Might sound confusing… sort of like copy and paste (and then rename the new theme)?

    …sorry just to clarify:

    not having the child theme rely at all on the parent theme.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Convert parent theme with modifications to a Child theme?’ is closed to new replies.