我使用的是子主题,需要为滑块登记样式表。css文件位于父主题目录(即/parent-theme/css/flexislider.css )的文件夹中。
我使用一个插件创建了子主题,该插件使用以下代码向子主题目录添加了一个functions.php文件:
<?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( 'child-style',get_stylesheet_directory_uri() . '/style.css',array('parent-style')
);
}我想我必须在上面引用flexislider.css的函数中添加另一个条目,但我不太确定如何做。
发布于 2016-02-25 21:38:56
*更新
根据您添加到问题中的内容,您应该能够添加到该函数中并注册样式表。整个功能如下所示:
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( 'child-style',get_stylesheet_directory_uri() . '/style.css',array('parent-style')
);
wp_enqueue_style('flex-slider',get_template_directory_uri() . '/css/flexislider.css');
}我对子主题没有多少经验,但按照该函数中的模型,我认为get_template_directory指向父主题,而不是子主题,您说柔性版代码位于其子主题。
https://stackoverflow.com/questions/35638653
复制相似问题