【发布时间】:2015-02-25 18:30:50
【问题描述】:
我从 Casper WP 主题创建了一个子主题。它被称为 casper-child,Casper 父主题位于名为“casper-master”的文件夹中。这是我正在正确读取的子 style.css 文件(背景颜色确实变为粉红色)。
/*
Theme Name: Casper Child
Description: Child theme for Casper theme
Author: Grant
Template: casper-master
*/
body { background-color: pink; }
我的问题是我的 functions.php 文件没有被读取/工作。
我的子主题的 functions.php 位于此处: /wp-content/themes/casper-child/functions.php
父函数.php 文件位于 /wp-content/themes/casper-master/functions.php
我孩子的functions.php中的代码是:
<?php
add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts' );
function my_child_theme_scripts() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
父主题仍未加载。任何想法为什么?我似乎无法在 functions.php 文件中得到任何东西,没有带有重定向或任何东西的自定义函数。感觉文件没有被读取。
【问题讨论】:
-
做双重,三重确保你的文件名是functions.php而不是function.php
-
谢谢,Peter,由于文件命名错误,我花了 2 个小时调试...
标签: php wordpress function themes