首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >子主题及其父主题都标识为父主题wordpress

子主题及其父主题都标识为父主题wordpress
EN

Stack Overflow用户
提问于 2018-04-07 00:19:31
回答 1查看 85关注 0票数 0

我正试图在wordpress上安装一个子主题。无论出于什么原因,我都不能安装它,因为它说这两个主题都标识为子主题。我有一个问题,当我创建我的孩子主题标题,所以我进入到wordpress的代码,只是复制他们的风格,并取代了相关的信息。以下是常规主题的style.css:

代码语言:javascript
复制
/*
 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
*/

关于儿童的主题

代码语言:javascript
复制
/*
 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代码

代码语言:javascript
复制
<?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' );
?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-07 00:25:45

子主题中的模板行对应于父主题的目录名。如果父主题位于一个名为"consulting“的目录中,那么在子主题的标题中就需要这样的内容:

代码语言:javascript
复制
Template: consulting

将模板行完全排除在父主题之外。

在常规主题的style.css中使用这个:

代码语言:javascript
复制
/*
 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
*/

假设您的父主题位于“咨询”目录中,请在您的子主题的style.css中使用它:

代码语言:javascript
复制
/*
 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
*/
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49702574

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档