【发布时间】:2016-12-10 12:27:44
【问题描述】:
我正在制作 wordpress 设计,并使用 wp_register_style 和 wp_enqueue_style 函数将其包含在内。 function.php 中的代码如下:
function themeSetup (){
wp_register_style( 'prostyle', get_template_directory_uri() .'/common/prostyle.css', array(), null, 'all' );
wp_enqueue_style( 'prostyle' );
wp_register_style( 'style', get_stylesheet_uri(), array(), null, 'all' );
wp_enqueue_style( 'style' );
wp_register_script( 'JqueryCDN', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', '', null, false );
wp_enqueue_script( 'JqueryCDN' );
wp_register_script( 'proscript', get_template_directory_uri() .'/common/proscript.js', '', null, false, false );
wp_enqueue_script( 'proscript' );
}
add_action('wp_enqueue_scripts', 'themeSetup');
主要问题:我之前编写的 css 正在网站上运行,但包含在同一文件中的每个新 css 规则既没有显示在浏览器上,也没有应用于元素。
请告诉我这些代码中缺少什么。如果 wp_register_script 或 style 函数有任何错误,请告诉我。
【问题讨论】:
-
刷新浏览器缓存 (CTRL+F5) 可能没有注意到 css 文件已更改,因此浏览器不会重新下载
-
是的,它有效,但我不明白为什么它不会发生在简单的点击?是因为wordpress功能吗?有什么解决办法吗?
-
这不是 WP 问题,而是一般缓存问题
-
感谢@riggs 的解决方案