-1

I'm trying to create a child theme of my current theme while maintaining the changes that I've made to the parent theme using its own options in the Appearance -> Customise panel.

However, as has become expected, I'm finding that the Codex is absolutely abysmal when it comes to documentation on this stuff.

I've created a folder called custom-theme, and that folder contains a functions.php and style.css.

style.css contains the following:

/*!
Theme Name: Custom Theme
Theme Author: My Name
Version: 1.0.0
Template: original-theme
Tags: blog, e-commerce, wide-blocks, block-styles, grid-layout, one-column, two-columns, three-columns, four-columns, right-sidebar, left-sidebar, translation-ready, custom-colors, custom-logo, custom-menu, featured-images, footer-widgets, full-width-template, theme-options, threaded-comments
*/

And functions.php contains the following:

<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {

    $parent_style = 'original-theme-style'; //

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'custom-theme-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style )
    );
}
?>

...as recommended by the Codex entry on child themes (actually the Codex also recommends including wp_get_theme()-&amp;gt;get('Version'), but doing so breaks the site entirely).

Despite all of the above, my site is still only showing the default styles of my parent theme, and includes none of the changes that I've made to it using the Customise panel.

The Codex also says:

The following example function will only work if your Parent Theme uses only one main style.css to hold all of the css. If your child theme has more than one .css file (eg. ie.css, style.css, main.css) then you will have to make sure to maintain all of the Parent Theme dependencies.

My parent theme does have several such files:

/admin/dashboard/static/bundle/main.css
/static/bundle/customizer-controls.css
/static/bundle/editor.css
/static/bundle/main.css
/static/bundle/options.css
/static/bundle/woocommerce.css

Unfortunately, the Codex leaves me to figure out myself what exactly "maintain all of the Parent Theme dependencies" means, because I've spent the last few hours attempting to do so to no luck.

How exactly do I create a child theme without losing changes made to the parent in the Customise panel?

Thanks in advance, I'd really appreciate the help trying to do what should be such a basic thing for such a widely-used piece of software.

  • Why was I downvoted for this? It's a perfectly valid question that has no answer in any official documentation or on any other question. – Prometheus May 23 '19 at 1:31
1

Actually, creating a Child Theme is well documented in the Codex along with lots of tutorials.

As for changes you make to the Customization screen in the parent theme, you'll need to export those and then import them into your Child Theme. The Child Theme doesn't inherit Customizations (I think). But there are Customization export/import plugins that will help with that. They will get all of the parent theme's customizations into the private theme.

Not sure that you need any extra code in the Child functions.php file. All of that should be handled as the Child Theme is loaded. As I understand it, the Child theme is loaded first, then the Parent, so anything missing from the Child is loaded from the Parent.

(Also, not sure why the downvote. I'm not a big fan of downvotes. I figure any question asked here is important to the person asking the question, and deserves the politeness of a reply, even if it is to remind them [gently] of the proper questions to ask.)

| improve this answer | |
  • 1
    There isn't a native way to export customiser settings and import them, so I think you'd need to provide a method to do that for this to be a useful answer. – Jacob Peattie May 25 '19 at 13:22
  • My answer says "But there are Customization export/import plugins that will help with that. They will get all of the parent theme's customizations into the private theme.", so I did provide info about plugins that will export/import Customizations. – Rick Hellewell May 25 '19 at 17:26
  • Thanks for the answer, Rick. How are you defining extra code - is nothing needed in the functions.php file at all, or just the lines that the Codex includes? – Prometheus May 26 '19 at 0:25
  • Assuming that you haven't made any changes to theme code (you shouldn't), all you need is the export/import of the Customization you made to the primary theme. With the main theme active, add the import/export plugin, then export. Then make the Child theme active, and use the same theme to import the settings you exported (into a local file, probably). Then the site will look like it did (with all the customizations), and you can add features/functions/templates/whatever to the child theme files. When the parent theme is updated, your changes are still there. That's why use child themes. – Rick Hellewell May 26 '19 at 1:44
  • @RickHellewell Do you know of an actual plugin that allows for exporting and importing Customisations? I've been unable to find one at all. – Prometheus May 27 '19 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.