我正在尝试在wordpress上安装一个子主题。 无论出于何种原因,我都无法安装它,因为它说两个主题都标识为子主题。当我创建我的子主题标题时,我遇到了一个问题,所以我进入了wordpress代码,只是复制了他们的样式并替换了相关信息。以下是常规主题的样式.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
*/
我知道它们区分大小写,所以我确保所有内容都匹配,但仍然没有。 感谢您的帮助。
编辑:
以下是函数.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' );
?>
子主题中的"模板"行对应于父主题的目录名称。如果您的父主题位于名为"咨询"的目录中,那么这就是您希望在子主题的标题中的内容:
Template: consulting
将模板行完全排除在父主题之外。
在常规主题的样式中使用它.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
*/
假设您的父主题位于"咨询"目录中,请在子主题的样式中使用它.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
*/