WordPress.org

Ready to get started?Download WordPress

Forums

Converting Non-Child Custom Theme to Child Theme (15 posts)

  1. Ben1011
    Member
    Posted 10 months ago #

    Hi, I'm working on a site that a developer converted to WordPress by modifying the Twenty Eleven directly. The version of WordPress is 3.3.2, and I'm trying to update the version so that I can use certain plugins, but I can't get the update to work without the whole site blowing up.

    So I tried creating a child theme of the customized Twenty Eleven theme following the instructions on creating child themes from the Codex as best as I could. I created a new folder under Themes with the name twentyeleven-child, I copied the customized style.css, pasted in the new directory, and modified the theme name to 'Twenty Eleven Child' and the template to 'twentyeleven'. I then copied all of the other files from the customized parent twentyeleven folder to my twentyeleven-child folder, except for functions.php. I activated my child theme and it worked fine (when functions.php was copied to the child folder, it didn't work). I then downloaded the most recent version of twentyeleven, and copied the files into the parent twentyeleven folder. Now the layout of the site is all messed up.

    What do I need to do to create a child theme that is a copy of the custom parent theme, and be able to update WordPress? Is there a certain subset of files that I need to copy over to the child theme directory?

    Thanks for you help.

  2. Andrew
    Forum Moderator
    Posted 10 months ago #

    I then downloaded the most recent version of twentyeleven, and copied the files into the parent twentyeleven folder.

    How come you copied the files into the parent twentyeleven folder? What files did you copy over, the modified ones?

  3. Ben1011
    Member
    Posted 10 months ago #

    Sorry, I wasn't very clear about that. I meant that I copied the files of the most recent version of Twenty Eleven into the parent folder, in order to update the version. I left the modified files in the child directory.

  4. WPyogi
    Volunteer Moderator
    Posted 10 months ago #

    I'm confused by what you are asking - if you want to update the theme per twentyeleven, copying the custom theme as the parent contradicts that.

  5. WPyogi
    Volunteer Moderator
    Posted 10 months ago #

    It sounds like you are on the right track with what you did initially. Did you clear any caching on your site and browser? Are you sure the child theme was set up and working correctly?

    If yes to the above, you could also try using http://www.diffchecker.com/ to compare the current theme files to your modified versions to help you track down what's going on.

  6. Ben1011
    Member
    Posted 10 months ago #

    Thanks. What I did was create a directory under themes called twentyeleven-child, and I copied the customized set of files from the parent twentyeleven folder to twentyeleven-child, except for functions.php. At this point the child theme worked fine.

    I then copied the most recent version of twentyeleven to the parent folder, and the child theme stopped working.

    I actually did a dif using dif tool but still couldn't tell which files need to be where. I know functions.php can't be the same in both the parent and child folders. I need the customized files to be in the child folder. Are there any other of these types of rules that I'm not aware of?

  7. WPyogi
    Volunteer Moderator
    Posted 10 months ago #

    I copied the customized set of files from the parent twentyeleven folder to twentyeleven-child, except for functions.php. At this point the child theme worked fine.

    If the child is a copy of the modified parent (except functions), then the child isn't really changing anything yet - so it would be expected to be the same. But just to be sure, was the child theme activated and "working" - i.e. make a change to the child theme style.css file - and see if it "works" - is visible, etc.

    I then copied the most recent version of twentyeleven to the parent folder, and the child theme stopped working.

    What do you mean it stopped working? Did you delete the modified copy first - sometimes overwriting won't work well - so deleting twentyeleven and reinstalling (new) might be worth a try. But, depending on how the theme was modified (i.e. what's in the child theme and what's not in the functions.php file), it might not work correctly even so.

    The general rules are the style.css file should contain only changes - but in your case, if they are extensive and/or the modifications to the theme are extensive, that might be complicated or not work. Did you put the required header section in the child style.css file though?

    For .php files except functions, yes, copies go in the child theme.

    Functions depends on the changes.

  8. Ben1011
    Member
    Posted 10 months ago #

    So maybe it was a caching issue (or user error), because I just repeated all the steps I listed above again, and now it looks fine. Was able to upgrade WordPress to 3.6, and everything's intact. So issue resolved.

    Thanks so much for your help.

  9. WPyogi
    Volunteer Moderator
    Posted 10 months ago #

    Wow - awesome - I love outcomes like this :)!

  10. zzzbra
    Member
    Posted 9 months ago #

    Technically I'd like the ask the same question as the OP but it seems that they went about creating their child theme from the custom theme in a different manner than I.

    In my case I am the original developer of m custom theme. However I'd like it to be future proof so I am attempting to convert it to a child theme. I am aware of all the php files I modified. I have created a sub-directory for my child theme. The CSS is properl formatted. At this point I have to ask, how can I format my functions.php so that it works with this child theme? I am aware that I need to reverse the order of the functions listed or something.

    My main problem however has to do with migrating the database from the old custom theme to my present child theme. When I set up this child theme I did a fresh install of WordPress. In any case I got it up and running with a new database. However I would like to simply have this child theme use the previous theme's MySQL database. Merely editing the Child Theme's WP_Config information so that the child theme points to the old database (they are both currently local installs on MAMP) just brings me a white page. Could this simply be because I have yet to properly configure the functions.php file for the child theme? Or, as I suspect, are there a good number of changes (maybe search and replaces) to be made to the old database so that it works with my child theme, and if so, what changes?

    I apologize if this has been asked before but I have been unable to find an answer after two days of searching. Any information would be greatly appreciated, thank you!

  11. WPyogi
    Volunteer Moderator
    Posted 9 months ago #

    However I'd like it to be future proof so I am attempting to convert it to a child theme.

    What do you mean by the above? Future proof from what? If it's a custom theme, presumably there won't be updates to the theme except those you do?

  12. zzzbra
    Member
    Posted 9 months ago #

    To the best of my knowledge, custom themes are less stable than child themes. If you update WP, there's a high probability that the site might break.

    My reasons are also more just that I want to consolidate all my changes and creating a child theme seems to be cleanest way of doing so. Again, the information I'm looking for:
    1. How to restructure my functions.php file for a child theme
    2. How to make the MySQL database for my custom theme work for this new child theme for which everything is the same, except the file directories.

  13. WPyogi
    Volunteer Moderator
    Posted 9 months ago #

    custom themes are less stable than child themes. If you update WP, there's a high probability that the site might break.

    No, a child theme of a custom theme would not be any more stable than the parent theme.

    Info on child themes:

    http://codex.wordpress.org/Child_Themes

  14. zzzbra
    Member
    Posted 9 months ago #

    Maybe so. It doesn't change what I'm trying to do here.

  15. WPyogi
    Volunteer Moderator
    Posted 9 months ago #

    You should not need to change anything in the database and the functions file question is explained in the article linked above.

Reply

You must log in to post.

About this Topic