首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Wordpress子主题中登记第二个样式表?

如何在Wordpress子主题中登记第二个样式表?
EN

Stack Overflow用户
提问于 2016-02-25 21:25:02
回答 1查看 2.2K关注 0票数 2

我使用的是子主题,需要为滑块登记样式表。css文件位于父主题目录(即/parent-theme/css/flexislider.css )的文件夹中。

我使用一个插件创建了子主题,该插件使用以下代码向子主题目录添加了一个functions.php文件:

代码语言:javascript
复制
<?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的函数中添加另一个条目,但我不太确定如何做。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-25 21:38:56

*更新

根据您添加到问题中的内容,您应该能够添加到该函数中并注册样式表。整个功能如下所示:

代码语言:javascript
复制
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指向父主题,而不是子主题,您说柔性版代码位于其子主题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35638653

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档