如何向“CSS顶部,JavaScript底部”Wordpress函数添加异常

如何向“CSS顶部,JavaScript底部”Wordpress函数添加异常,javascript,wordpress,function,Javascript,Wordpress,Function,如何为这个wordpress函数代码添加一个例外,我有Java脚本需要在它们所在的位置,这样图像滑块才能正常工作 示例:我希望从此函数中排除的文件;slider1.js slider2.js slider1.css slider2.css //Automatically move JavaScript code to page footer, speeding up page loading time. function footer_enqueue_scripts() { remove_act

如何为这个wordpress函数代码添加一个例外,我有Java脚本需要在它们所在的位置,这样图像滑块才能正常工作

示例:我希望从此函数中排除的文件;slider1.js slider2.js slider1.css slider2.css

//Automatically move JavaScript code to page footer, speeding up page loading time.
function footer_enqueue_scripts() {
remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
add_action('wp_footer', 'wp_print_scripts', 5);
add_action('wp_footer', 'wp_enqueue_scripts', 5);
add_action('wp_footer', 'wp_print_head_scripts', 5);
}
add_action('after_setup_theme', 'footer_enqueue_scripts');

您可以将脚本出列:

您将按以下方式退出队列:

wp_enqueue_script( 'my_slider_script', plugin_dir_url( __FILE__ ) . 'slider1.js' );
//CALL DEQUEUE BEFORE YOU CALL add_action('wp_footer', 'wp_enqueue_scripts', 5);
wp_dequeue_script( 'my_slider_script' );

这是在php端服务器端而不是客户端运行的,因此您不能在那里执行try-catch,您应该在客户端创建try-and-catch,javascript@ncubica他不是指程序上的例外,他是指规则的例外。谢谢你。它不起作用。我想排除的文件是:jquery-core.js和jquery.timers.js,如果你能在我发布的代码中实现它们,那就太好了,因为我无法理解我所做的是对的还是错的,因为页面变得一团糟。无论如何谢谢你
//CALL DEQUEUE BEFORE YOU CALL add_action('wp_footer', 'wp_enqueue_scripts', 5);
wp_dequeue_script( 'my_slider_script' );