所以我一直在阅读这里和Wordpress官方网站上的说明,但我的儿童主题仍然存在问题。我正在使用敏捷主题,并将敏捷child设置为我的child主题的目录。在那里我有我的风格.css:
/*
Theme Name: Agility Child Theme
Theme URI: themeforest.net/item/agility-responsive-html5-wordpress-theme/2336028
Description: Agility Child Theme
Author: *****
Author URI: *****
Template: agility
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
/* =Theme customization starts here --------------- */
然后,在另一个文件夹(样式表)中,我有布局.css:
/*
Theme Name: Agility Child Theme
Theme URI: themeforest.net/item/agility-responsive-html5-wordpress-theme/2336028
Description: Agility Child Theme
Author: *****
Author URI: *****
Template: agility
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
/* =Theme customization starts here --------------- */
#colophon {
background: #fff;
border-top: 2px solid #ddd;
}
然后,返回主目录,functions.hp:
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'parent-style', get_template_directory_uri() . 'stylesheets/layout.css' );
}
?>
WP中的子主题是活动的,但我的CSS没有更改为layout.CSS(或该主题使用的其他CSS;style.CSS基本上是免费使用的)。我是否错误地使用了functions.php?
get_template_directory_uri()
返回您正在使用的模板的目录(或者换句话说——父主题)。您可以改用get_bloginfo( 'stylesheet_directory' )
。这将获得当前主题的样式表目录。
每个入队的文件也应该有不同的id(你对两者都使用"父样式"。此外,你在第二行缺少一个斜杠。你的入队可能看起来像这样:
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
// This will include the parent theme's stylesheet
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
// This will include layouts.css from the child theme's "stylesheets" directory
wp_enqueue_style( 'layouts', get_bloginfo( 'stylesheet_directory' ) . '/stylesheets/layout.css' );
}
参考:
http://codex.wordpress.org/Child_Themeshttp://codex.wordpress.org/Function_Reference/get_bloginfohttp://codex.wordpress.org/Function_Reference/get_template_directory_uri