php - 无法创建 Wordpress 子主题
问题描述
因此,我正在尝试从 wordpress 主题“全屏代理”创建一个名为 Premierpas 的子主题。我在主题中创建了 Premierpas 文件夹,然后添加了一个包含该内容的 css 文件:
/*
Theme Name: Premier Pas
Author: Garga Le Noir
Template: fullscreen-agency
Version: 1.0.0
*/
和具有此内容的functions.php:
<?php
function premierpas_enqueue_styles() {
$parent_style = 'fullscreen-agency';
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 ),null);
}
我已经尝试了很多其他版本的函数代码,但都没有成功。当我尝试激活它时,我的网站就崩溃了。我只有一条消息告诉我存在技术问题,我收到一封电子邮件以激活恢复模式。我确信这个错误是微不足道的,如果我在浪费你的时间,我很抱歉,但我很坚持这个......任何帮助将不胜感激,在此先感谢
解决方案
我用你上面提到的代码创建了一个子主题,它对我有用。我所做的一项更改是我将父级设置为,twentyfifteen
因为我没有您的fullscreen-agency
父级主题。我假设你的文件路径是......
wp-content/themes/premierpas/style.css
wp-content/themes/premierpas/functions.php
有几件事要尝试...
- 删除您的 functions.php 文件。如果这样可以解决问题,那么您可能已经
premierpas_enqueue_styles()
在父主题中定义了或者存在一些相关的错误。 - 通过将以下内容添加到您的 wp-config.php 文件来启用 debug.log...
define( 'WP_DEBUG', true );
然后尝试重新激活子主题并查看您的 wp-content/debug.log 文件以查看是否有任何相关错误可以提供帮助您进一步排除故障。
推荐阅读
- ubuntu - 我已经在 Ubuntu 上构建了 Emgucv,那么下一步是什么?
- python - 无法使用 pymsql 获得正确的 SQL 语法,错误 1064
- javascript - 在给定纬度和经度的特定区域上启动 d3 地图
- r - 从 R 中的数据框中删除特定的重复值
- java - 如何找出模板变量可调用的属性
- python-3.x - 使用 Python OOP 的解析几何
- android - 谁能解释一下在 android 应用程序开发中创建 AlertDialog 的更好解决方案是什么?
- python - 为每个索引生成具有单独限制的所有排列
- ios - Swift - 比较单词和过滤
- angular - 如何在 Angular 表单中使用 setValidator 设置自定义验证器?