首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress @导入或排队,这段代码有意义吗?

Wordpress @导入或排队,这段代码有意义吗?
EN

Stack Overflow用户
提问于 2014-10-15 19:31:45
回答 1查看 1.2K关注 0票数 1

刚刚发现@import并不是导入样式表的最有效的方法。如果尝试在各种文件夹中导入多个父样式表,这是否有意义:

代码语言:javascript
复制
<?php
/**
 * Load the style sheet from the parent theme.
 *
 */
function theme_name_parent_styles() {

  // Enqueue the parent stylesheet
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/style.css', array(), '0.1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/custom-admin-style.css', array(), '1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/flexslider.css', array(), '1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/thumbfx.css', array(), '1', 'all' );
  wp_enqueue_style( 'theme-name-parent-style', get_template_directory_uri() . '/css/dynamic-css/options.css', array(), '1', 'all' );


  // Enqueue the parent rtl stylesheet
  if ( is_rtl() ) {
    wp_enqueue_style( 'theme-name-parent-style-rtl', get_template_directory_uri() . '/rtl.css', array(), '0.1', 'all' );
  }

}
add_action( 'wp_enqueue_scripts', 'theme_name_parent_styles' );
?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-15 21:25:22

第一条规则:遵循wordpress代码

代码语言:javascript
复制
<?php

add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
function enqueue_child_theme_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('parent-style')  );
}

下一次我将首先检查来源

问题解决了,谢谢您的疑难解答@m1ro。

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

https://stackoverflow.com/questions/26390598

复制
相关文章

相似问题

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