dongqishun6409 2015-02-25 18:30
浏览 40

Wordpress Child的主题functions.php未被阅读

I have created a child theme from the Casper WP theme. It is called casper-child, the Casper parent theme is in a folder called "casper-master". Here is my child style.css file that is being read correctly (the background color does change to pink).

/*
Theme Name: Casper Child
Description: Child theme for Casper theme
Author: Grant
Template: casper-master
*/
body { background-color: pink; }

My problem is that my functions.php file is not being read/working.

My functions.php for my child theme is located here: /wp-content/themes/casper-child/functions.php

The parents functions.php file is at /wp-content/themes/casper-master/functions.php

The code I have in my child's functions.php is:

<?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' );
}

The parent theme is still not being loaded. Any ideas why? I can't seem to get anything to work in the functions.php file, no custom functions with redirects or anything. It feels like the file is not being read.

  • 写回答

4条回答 默认 最新

  • douao1579 2015-02-25 21:07
    关注

    Most of the Wordpress documentation has add_action after the function, not sure if this will make a difference at all.

    Also in your example there is no closing ?>

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题