当我使用wp\\u register\\u script()和wp\\u enqueue\\u script()加载wordpress的jquery时,我得到了“没有收到包含以下信息的数据结果:
无法加载网页,因为服务器未发送数据。错误代码:ERR\\u EMPTY\\u RESPONSE
我要加载jquery的代码是
function theme_script(){
wp_deregister_script( \'jquery\' );
wp_register_script(\'jquery\',get_template_directory_uri().\'/sliderengine/jquery.js\');
wp_enqueue_scripts(\'jquery\');
wp_register_script(\'amazingslider\',get_template_directory_uri().\'/sliderengine/amazingslider.js\',array(\'jquery\'));
wp_enqueue_scripts(\'amazingslider\');
wp_register_script(\'initslider-1\',get_template_directory_uri().\'/sliderengine/initslider-1.js\',array(\'jquery\'));
wp_enqueue_scripts(\'initslider-1\');
}
add_action(\'wp_enqueue_scripts\',\'theme_script\');
最合适的回答,由SO网友:cybmeta 整理而成
您的代码错误。你弄糊涂了wp_enqeue_script
功能和wp_enqueue_scripts
行动它应该是:
function theme_script(){
wp_deregister_script( \'jquery\' );
wp_register_script(\'jquery\',get_template_directory_uri().\'/sliderengine/jquery.js\');
wp_enqueue_script(\'jquery\');
wp_register_script(\'amazingslider\',get_template_directory_uri().\'/sliderengine/amazingslider.js\',array(\'jquery\'));
wp_enqueue_script(\'amazingslider\');
wp_register_script(\'initslider-1\',get_template_directory_uri().\'/sliderengine/initslider-1.js\',array(\'jquery\'));
wp_enqueue_script(\'initslider-1\');
}
add_action(\'wp_enqueue_scripts\',\'theme_script\');