Wordpress在页脚中加载CSS
我如何才能让这个函数加载我的css在页脚,而不是在谷歌页面速度的头部。我已经在谷歌上搜索过它并尝试过,但我似乎无法让它工作Wordpress在页脚中加载CSS,wordpress,performance,footer,Wordpress,Performance,Footer,我如何才能让这个函数加载我的css在页脚,而不是在谷歌页面速度的头部。我已经在谷歌上搜索过它并尝试过,但我似乎无法让它工作 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_
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' );
更改添加操作('wp_脚本排队','broa_脚本排队');添加_操作('wp_footer','broa_script_enqueue') 更改添加操作('wp\u脚本排队','broa\u脚本排队');添加_操作('wp_footer','broa_script_enqueue') 您可以使用
get\u footer
hook。将此代码放在活动主题的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' );
这里已经描述了这个问题您可以使用
get\u footer
hook。将此代码放在活动主题的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' );
这个问题在这里已经描述过了当我这样做时('wp_enqueue_scripts','broa_script_enqueue');添加_操作('wp_footer','broa_script_enqueue');它不会加载css.function prefix\u add\u footer\u styles(),但当我这样做时,它不会出于任何原因加载我的样式。我在这里发帖之前就试过了。我没有php错误。但是这种风格不会加载;添加_操作('wp_footer','broa_script_enqueue');它不会加载css.function prefix\u add\u footer\u styles(),但当我这样做时,它不会出于任何原因加载我的样式。我在这里发帖之前就试过了。我没有php错误。但是这种风格不适合。