我想在主题中包含一个功能,该功能将覆盖以前包含的CSS文件中的样式。为此,我需要能够显示<style>
显示所有样式表后,在标题中。
有钩子做这个吗?
我想在主题中包含一个功能,该功能将覆盖以前包含的CSS文件中的样式。为此,我需要能够显示<style>
显示所有样式表后,在标题中。
有钩子做这个吗?
挂钩到wp_enqueue_scripts
具有高优先级编号。例如:
function load_my_style_wpse_90225() {
wp_register_style( \'mystyle\', get_template_directory_uri() .\'/path/to/stylesheet.css\');
wp_enqueue_style( \'mystyle\' );
}
add_action(\'wp_enqueue_scripts\',\'load_my_style_wpse_90225\',1000);
这应该是最后一行的合理负载。答案与此处基本相同:Wooslider custom css
虽然通常不建议这样做,但我们可以[wp_print_styles][1]
操作,在之后显示wp_head
, wp_enqueue_scripts
, 和wp_enqueue_styles
.
所以(在functions.php中):
function my_theme_custom_css_handler(){
echo \'<style>custom css here</style>\';
}
add_action(\'wp_print_styles\', \'my_theme_custom_css_handler\');
有关更多信息和操作的完整列表,您可以查看Action Reference in the WordPress Codex.我已经使用Git设置了新的shiny 3.5.1 WordPress,如下所示:http://clintberry.com/2011/speed-up-your-wordpress-development-cycle-with-git/(在步骤2之后停止;我还没有创建子主题)。我希望根主题能够自行发挥作用)我基本上拥有的与作者的Git项目相同:https://github.com/clintberry/WordPress我最后在头部部分添加了如下标签:<link rel=\"stylesheet\"