Php WordPress子主题未显示
我刚刚创建了一个子主题并激活了它。但是当我访问这个页面时,它是完全空白的 在显示中是themes文件夹,其中有我的父主题和子主题,下面是parent style.css中的站点详细信息,我只是将其复制并粘贴到子样式表中 functions.php如下所示:Php WordPress子主题未显示,php,wordpress,Php,Wordpress,我刚刚创建了一个子主题并激活了它。但是当我访问这个页面时,它是完全空白的 在显示中是themes文件夹,其中有我的父主题和子主题,下面是parent style.css中的站点详细信息,我只是将其复制并粘贴到子样式表中 functions.php如下所示: <?php function my_theme_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style,
<?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插件。 这很简单。你可以安装插件。去: 外观->主题
当你看到你的主题时,把鼠标悬停在上面,你会看到主题的细节。单击它,然后查找名为“创建子主题”的按钮。命名您的主题,单击“确定”…然后单击“vuala” 完全空白的页面可能是错误造成的。是
WP\u DEBUG
true
?@Andy Tschiersch。是,设置为true。我以前创建的子主题使用的是216th主题,wp-debug被设置为false,它工作了。现在我按照您的建议使用import,而不是functions.php,但它也可以工作@导入url('../sidimaag/style.css');这很有趣,因为之前,我用同样的过程使用了216th主题创建了子主题,它工作了,所以我真的不知道如何解决这个问题('wp_enqueue_scripts'、'sidimaag_child_theme_enqueue_styles');函数sidimaag_child_theme_enqueue_styles(){wp_enqueue_style('sidimaag',get_template_directory_uri()./style.css');}如果你能提供对WP的访问,我可以帮助你。@I.T.我希望我能给你访问权限。我正在本地主机上工作。好的,不用担心。你是否像我之前建议的那样在孩子的style.css中添加了模板:sidimaag?创建子主题非常简单,子主题应该只在style.css文件中可见。请检查你的路径并查看此视频: