【发布时间】:2014-12-01 00:29:24
【问题描述】:
我知道这个问题之前在 stackoverflow 上被问过,但在我的一生中,我无法让我的条件样式表加载并适用于所有版本的 IE。我感谢提前提供的任何帮助,这真的很影响我,我不知道从这里开始做什么。我还尝试在标题中加载 IE 样式表,但这似乎也不起作用。我的主题不是子主题。
这是我的函数代码:
function theme_styles() {
global $wp_styles;
wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'glyphicons_css', get_template_directory_uri() . '/css/glyphicons.css' );
wp_enqueue_style( 'glyphiconssocial_css', get_template_directory_uri() . '/css/social.css' );
wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
/**
* Load our IE-only stylesheet for all versions of IE:
* <!--[if IE]> ... <![endif]-->
*
* NOTE: It is also possible to just check and see if the $is_IE global in WordPress is set to true before
* calling the wp_enqueue_style() function. If you are trying to load a stylesheet for all browsers
* EXCEPT for IE, then you would HAVE to check the $is_IE global since WordPress doesn't have a way to
* properly handle non-IE conditional comments.
*/
wp_enqueue_style( 'ie_css', get_template_directory_uri() . '/ie.css', array('bootstrap_css', 'main_css') );
$wp_styles->add_data( 'ie_css', 'conditional', 'IE' );
} add_action( 'wp_enqueue_scripts', 'theme_styles' );
【问题讨论】: