我是wordpress主题开发的新手。现在,我在订购一些css时遇到了一些问题。
我的wordpress生成这样的头部标记
<head>
...
<link rel="stylesheet" type="text/css" href="http://localhost/wordpress/wp-content/themes/muarif/style.css">
...
<link rel="stylesheet" id="normalize-css" href="http://localhost/wordpress/wp-content/themes/muarif/inc/css/normalize.css?ver=4.1.1" type="text/css" media="all">
<link rel="stylesheet" id="bootstrap-css" href="http://localhost/wordpress/wp-content/themes/muarif/inc/css/bootstrap.css?ver=4.1.1" type="text/css" media="all">
...
</head>*编辑wp_enqueue_style
function site_script(){
wp_enqueue_style('normalize',get_template_directory_uri().'/inc/css/normalize.css');
wp_enqueue_style('bootstrap',get_template_directory_uri().'/inc/css/bootstrap.css');
//jquery script
wp_register_script('jquery',get_template_directory_uri().'/inc/js/jquery.js');
wp_enqueue_script('jquery');
//angular script
wp_register_script('angular',get_template_directory_uri().'/inc/js/angular.js');
wp_enqueue_script('angular');
//bootstrap script
wp_register_script('bootstrap',get_template_directory_uri().'/inc/js/bootstrap.min.js',array('jquery'));
wp_enqueue_script('bootstrap');
}
add_action('wp_enqueue_scripts','site_script');如果Style.css存在于主题中,它将自动加载。现在,我希望将style.css放在比其他css更低的位置,并将normalize.css放在最上面,以便覆盖每个样式表。我使用wp_enqueue_style并填充$deps参数。但这不会使任何事情发生。
有什么建议吗?
发布于 2015-03-12 03:02:47
在这个问题上,你能试一下这段代码而不是你的吗?此外,搜索和删除任何其他wp_enqueue_style,我认为默认的是加载在其他地方之前。还要检查它是否是在header.php中硬编码的
function site_script(){
wp_enqueue_style('normalize',get_template_directory_uri().'/inc/css/normalize.css');
wp_enqueue_style('bootstrap',get_template_directory_uri().'/inc/css/bootstrap.css');
wp_enqueue_style('theme_name',get_template_directory_uri().'/style.css');
//jquery script
wp_register_script('jquery',get_template_directory_uri().'/inc/js/jquery.js');
wp_enqueue_script('jquery');
//angular script
wp_register_script('angular',get_template_directory_uri().'/inc/js/angular.js');
wp_enqueue_script('angular');
//bootstrap script
wp_register_script('bootstrap',get_template_directory_uri().'/inc/js/bootstrap.min.js',array('jquery'));
wp_enqueue_script('bootstrap');
}
add_action('wp_enqueue_scripts','site_script');您还可能需要像这样更新jQuery部件:
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery',get_template_directory_uri().'/inc/js/jquery.js');
wp_enqueue_script('jquery');
}金融时报:script
https://stackoverflow.com/questions/29001052
复制相似问题