Php wp_enqueue_脚本不';不要像它应该的那样加载每一页的页脚
随后是以下格式:Php wp_enqueue_脚本不';不要像它应该的那样加载每一页的页脚,php,wordpress,Php,Wordpress,随后是以下格式: add_action('wp_enqueue_scripts', 'caffeine_load_scripts'); function caffeine_load_scripts(){ wp_register_script('bootstrap-modal-js' , get_stylesheet_directory_uri() . '/bootstrap/bootstrap-modal.js', array('jquery'), '1', true); w
add_action('wp_enqueue_scripts', 'caffeine_load_scripts');
function caffeine_load_scripts(){
wp_register_script('bootstrap-modal-js' , get_stylesheet_directory_uri() . '/bootstrap/bootstrap-modal.js', array('jquery'), '1', true);
wp_register_script('bootstrap-modal-patch-js' , get_stylesheet_directory_uri() . '/bootstrap/patch/bootstrap-modal-patch.js', array('jquery'), '1', true);
wp_register_script('bootstrap-modal-manager-js' , get_stylesheet_directory_uri() . '/bootstrap/patch/bootstrap-modalmanager.js', array('jquery'), '1', true);
wp_enqueue_style('bootstrap-css', get_stylesheet_directory_uri() . "/bootstrap/bootstrap.min.css", array(), '1', 'all');
wp_enqueue_script('bootstrap-modal-js');
wp_enqueue_script('bootstrap-modal-patch-js');
wp_enqueue_script('bootstrap-modal-manager-js');
}
他们在主页上加载页脚,但在任何其他页面上加载页首
有人能告诉我为什么吗?您需要有条件地将脚本和样式表排队。你不能再排队了 你需要这样做
add_action( 'wp_enqueue_scripts', 'remove_scripts_home', 99 );
function remove_scripts_home() {
if ( is_front_page() || is_home() ) {
//here I dequeue scripts and styles not used on home page
}
}
add_action( 'wp_enqueue_scripts', 'remove_scripts_about', 99 );
function remove_scripts_about() {
if ( is_page(412) ) {
//here I dequeue scripts and styles not used on the about page
}
}
add_action(“wp_排队_脚本”、“咖啡因_加载_脚本”);
函数\u加载\u脚本(){
如果(是首页()| |是首页()){
}其他(见第412页){
}否则{
}
或者你可以使用
add_action('wp_enqueue_scripts', 'caffeine_load_scripts');
function caffeine_load_scripts(){
if ( is_front_page() || is_home() ) {
<--- Load the scripts you need on homepage, if nothing, leave this empty --->
}elseif( is_page(412) ) {
<--- Load scripts for page 412, if nothing, leave this empty --->
}else{
<--- Load all your scripts --->
}
add_action(“wp_排队_脚本”、“咖啡因_加载_脚本”);
函数\u加载\u脚本(){
如果(false==is_首页()| | false==is_首页()| | false==is_首页(412)){
}
如果您不想在这些页面上加载任何脚本
add_action('wp_enqueue_scripts', 'caffeine_load_scripts');
function caffeine_load_scripts(){
if( false == is_front_page() || false == is_home() || false == is_page(412) ) {
<--- load all your scripts --->
}