繁体   English   中英

WordPress儿童主题没有显示

[英]WordPress child theme not showing

我刚刚创建了一个子主题并激活了它。但是当我访问该页面时,它完全是空白的。

在显示是主题文件夹,我有我的父主题和孩子,然后下面是父style.css的网站详细信息,我简单地复制并粘贴到子样式表。

在此输入图像描述

functions.php看起来像这样:

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'parent-style';

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

如照片所示,主题是活跃的。

在此输入图像描述

如何创建子主题并将其显示为父主题?

您不应该只复制父样式,最好创建一个新样式并导入父样式。 您还需要将模板指定为父主题。 试试这个:

/*
    Theme Name:   Sidimaag Child Theme
    Theme URI:    http://underscores.me
    Description:  Sidimaag Child Theme
    Author:       mytheme
    Author URI:   http://mytheme.co.za
    Template:     sidimaag
    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:  sidimaag
    */

然后你可以使用@import导入父类的样式,如下所示:

@import url('path_to_parent_theme/style.css');

为了挽救你的生命,只需安装themify插件即可。 这很简单。 您安装插件。 转到:外观 - >主题当您看到主题时,将鼠标悬停在主题上,您将看到主题详细信息。 单击它,然后查找名为:create child theme..name your theme的按钮,单击ok ...和vuala !!!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM