Child theme not visible

时间:2016-11-12 作者:Slenkra

我要覆盖父主题。我尝试了下面的代码(以及parent-style 直到panoramic-style 在里面functions.php 但没有运气)。在所有修改之后,我刷新了管理页面,无法看到子主题。我做错了什么?

文件夹层次结构:

家长:

E:\\xampp\\htdocs\\wordpress\\wp-content\\themes\\panoramic

子项:

E:\\xampp\\htdocs\\wordpress\\wp-content\\themes\\panoramic\\panoramic-child

在子文件夹中,我创建了style.css 和afunctions.php让我们看看一些代码:

panoramic-child/functions.php

<?php

add_action( \'wp_enqueue_scripts\', \'theme_enqueue_styles\' );
function theme_enqueue_styles() {
  wp_enqueue_style( \'panoramic\', get_template_directory_uri() . \'/style.css\' );
  wp_enqueue_style( \'panoramic-child\', get_stylesheet_uri());
}

?>

panoramic-child/styles.css

/*
 * Theme Name: Panoramic child
 * Theme URI: http://www.outtheboxthemes.com/themes/panoramic/
 * Author: Out the Box
 * Author URI: http://www.outtheboxthemes.com/
 * Description: Panoramic is a well designed, fully responsive theme
 * Version: 1.0.18
 * License: GNU General Public License v2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: panoramic-child
 * Template: panoramic
 */

.page-id-2 #secondary{
  display:none;
}
styles.css (父级标题注释部分)

/*
 * Theme Name: Panoramic
 * Theme URI: http://www.outtheboxthemes.com/themes/panoramic/
 * Author: Out the Box
 * Author URI: http://www.outtheboxthemes.com/
 * Description: Panoramic is a well designed, fully responsive theme with a homepage slider that\'s easy to customize and offers 5 star support. The subtle design features give it a premium feel and the wide range of flexible theme options help you create a variety of sites from a simple blog to a fully functional online eCommerce store. Used in conjunction with SiteOrigin\'s drag and drop Page Builder plugin, you can easily build beautiful page layouts with no coding knowledge to create any website from travel to business to food, decor, lifestyle, sport and more. Panoramic integrates seamlessly with the following popular free plugins: SiteOrigin\'s Page Builder, Contact Form 7 and WooCommerce.
 * Version: 1.0.18
 * License: GNU General Public License v2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: panoramic
 * Template: panoramic
 */

1 个回复
最合适的回答,由SO网友:Dmitry Mayorov 整理而成

问题出在文件夹结构中。子主题应与父主题位于同一目录中。即:

E:\\xampp\\htdocs\\wordpress\\wp-content\\themes\\panoramic-child
非:

E:\\xampp\\htdocs\\wordpress\\wp-content\\themes\\panoramic\\panoramic-child
此外,在父主题的标题注释中不需要这一行style.css:

Template: panoramic
它仅用于子主题。

相关推荐

About wordpress child themes

我对WordPress和儿童主题有一些问题。据我所知,如果我不想在更新主题时失去任何东西,使用子主题是很重要的。我是WordPress的初学者,到目前为止,我一直在使用PageBuilder(管理面板上的板载自定义选项)自定义我的网站,并在“附加CSS”选项中加入几行CSS。所有这些都是在主主题上完成的(只是玩转尝试学习),现在我想开始使用一个儿童主题。问题如下:我不知道我是否可以像通过管理界面设计父主题那样设计我的子主题,或者我是否必须通过文本编辑器(在我的计算机上,然后通过FTP等方式上传)对所有内容