我正在尝试在wordpress上安装子主题。无论出于何种原因我无法安装它,因为它说两个主题都标识为子主题。当我创建我的子主题标题时,我遇到了一个问题,所以我进入了wordpress codex,只是复制了他们的样式并替换了相关信息。这是常规主题的style.css:
/*
Theme Name: consulting
Theme URI: http://example.com/twenty-fifteen-child/
Description: consulting
Author: John Doe
Author URI: http://example.com
Template: consulting
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: consulting
*/
和儿童主题
/*
Theme Name: consulting-child
Theme URI: http://example.com/twenty-fifteen-child/
Description: consulting child theme
Author: John Doe
Author URI: http://example.com
Template: consulting-child
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: consulting-child
*/
我知道他们对案件非常敏感,所以我确保一切都匹配,但仍然没有。谢谢您的帮助。
编辑:
这里是functions.php代码
<?php
function my_theme_enqueue_styles() {
$parent_style = 'consulting-style'; // This is 'consulting-style' for the consulting theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'consulting-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
答案 0 :(得分:0)
子主题中的模板行对应于父主题的目录名称。如果您的父主题位于名为&#34; consulting&#34;的目录中,那么这就是您想要的子主题标题:
Template: consulting
将模板行完全保留在父主题之外。
在常规主题的style.css中使用它:
/*
Theme Name: consulting
Theme URI: http://example.com/consulting/
Description: consulting
Author: John Doe
Author URI: http://example.com
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: consulting
*/
假设您的父主题位于&#34;咨询&#34;目录,在您的子主题的style.css中使用它:
/*
Theme Name: consulting-child
Theme URI: http://example.com/consulting-child/
Description: consulting-child
Author: John Doe
Author URI: http://example.com
Template: consulting
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: consulting-child
*/