Wordpress在页脚中加载CSS [英] Wordpress load CSS In footer
本文介绍了Wordpress在页脚中加载CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何获得此功能以将我的CSS加载到页脚而不是顶部以获取Google页面速度.我已经用谷歌搜索并尝试了,但是我似乎无法使它工作.
How can I get this function to load my css in the footer and not in the head for google page speed. I've googled it and tried but I cant seem to get it to work.
function broa_script_enqueue() {
wp_enqueue_style('boostrapcss', get_template_directory_uri() . '/css/bootstrap.css', array(), '4.0.0', 'all');
wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/style.css', array(), '1.0.0', 'all');
wp_enqueue_style('animatecss', get_template_directory_uri() . '/css/animate.css', array(), '1.0.0', 'all');
}
add_action( 'wp_enqueue_scripts', 'broa_script_enqueue' );
推荐答案
您可以使用get_footer
挂钩.将此代码放在活动主题的function.php中.
You can use get_footer
hook. Put this code in your active theme's function.php.
function prefix_add_footer_styles() {
wp_enqueue_style('boostrapcss', get_template_directory_uri() . '/css/bootstrap.css', array(), '4.0.0', 'all');
wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/style.css', array(), '1.0.0', 'all');
wp_enqueue_style('animatecss', get_template_directory_uri() . '/css/animate.css', array(), '1.0.0', 'all');
};
add_action( 'get_footer', 'prefix_add_footer_styles' );
此问题已在此处描述 https://wordpress.stackexchange .com/questions/186065/how-to-load-css-in-the-footer
这篇关于Wordpress在页脚中加载CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文