[英]WordPress child theme not showing
I just created a child theme and activated it.But when I visit the page,it's completely blank. 我刚刚创建了一个子主题并激活了它。但是当我访问该页面时,它完全是空白的。
In the display is the themes folder where I have my parent theme and the child,then below is the site details from the parent style.css which I simply copied and pasted to the child stylesheet. 在显示是主题文件夹,我有我的父主题和孩子,然后下面是父style.css的网站详细信息,我简单地复制并粘贴到子样式表。
functions.php looks like this: 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' );
?>
As the photo shows,the theme is active. 如照片所示,主题是活跃的。
How can I create a child theme and make it visible as the parent theme? 如何创建子主题并将其显示为父主题?
You shouldn't just copy the parent style, it's better to create a new one and import the parent's. 您不应该只复制父样式,最好创建一个新样式并导入父样式。 You also need to specify the Template as the parent theme. 您还需要将模板指定为父主题。 Try using this: 试试这个:
/*
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
*/
Then you can use @import to import the parent's style like this: 然后你可以使用@import导入父类的样式,如下所示:
@import url('path_to_parent_theme/style.css');
To save your life,just install themify plugin. 为了挽救你的生命,只需安装themify插件即可。 It is very straightforward. 这很简单。 You install the plugin. 您安装插件。 Go to: Appearance -> Themes When you see your themes,hover over it and you'll see Theme Details. 转到:外观 - >主题当您看到主题时,将鼠标悬停在主题上,您将看到主题详细信息。 Click on it and then look for the button named: create child theme..name your theme,click ok...and vuala!!! 单击它,然后查找名为:create child theme..name your theme的按钮,单击ok ...和vuala !!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.