admin管理员组文章数量:1426655
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()-&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.
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()-&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.
Share Improve this question asked May 22, 2019 at 23:27 Hashim AzizHashim Aziz 2977 silver badges19 bronze badges 1- 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. – Hashim Aziz Commented May 23, 2019 at 1:31
1 Answer
Reset to default 1Actually, 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.)
本文标签: localhostHow to create a child theme without losing changes made to parent
版权声明:本文标题:localhost - How to create a child theme without losing changes made to parent 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745471522a2659772.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论