wp_deregister_script()函数主要是用来去除WordPress本身自带的一些js文件,一把情况下,我们制作的WordPress主题的前端会加载一些比如jquery文件,这些文件可能与我们的前端源码有冲突导致网页显示不正常,这时候可以使用这个函数来去除冲突的WordPress自带JS文件。
语法
wp_deregister_script( string $handle )
参数
$handle (字符串) (必须) 此处为要移除的脚本handle名称。默认: None
实例
if ( !is_admin() ) {
function my_init_method() {
wp_deregister_script( 'jquery' );
}
add_action('init', 'my_init_method');
}
禁用自动保存功能的方法(添加到 functions.php
中)
add_action('wp_print_scripts','disable_autosave');
function disable_autosave(){ wp_deregister_script('autosave'); }
近期评论