这里有多个错误。
您将CSS和JS放在同一个钩子上,而JS可能使用的钩子是错误的wp_enqueue_scripts
对于CSS,您可以使用wp_print_styles
wp_register_script
/ wp_enqueue_script
仅接受4个参数你应该register 您的脚本和enqueue only the last one 及其依赖项。使用第三个参数定义这些请尝试以下代码:
functions.php
add_action(\'wp_print_styles\', \'wpse28490_enqueueStyles\');
function wpse28490_enqueueStyles() {
wp_register_style(\'fancyboxStyle\', get_template_directory_uri() . \'/css/fancybox.css\');
wp_enqueue_style(\'fancyboxStyle\');
}
add_action(\'wp_enqueue_scripts\', \'wpse28490_enqueueScripts\');
function wpse28490_enqueueScripts() {
if(!is_admin()) {
// If our site is using SSL, we should load our external scripts also in HTTPS
$protocol = (is_ssl()) ? \'https://\' : \'http://\';
// jQuery
wp_deregister_script(\'jquery\');
wp_register_script(\'jquery\', $protocol . \'ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js\', array(), \'1.6.2\', true);
// Custom scripts
wp_register_script(\'jquery-easing\', get_template_directory_uri() . \'/js/jquery.easing-1.3.pack.js\', array(\'jquery\'), \'1.0\', true);
wp_register_script(\'jquery-mouseWheel\', get_template_directory_uri() . \'/js/jquery.mousewheel-3.0.4.pack.js\', array(\'jquery\'), \'1.0\', true);
wp_register_script(\'jquery-fancybox\', get_template_directory_uri() . \'/js/jquery.fancybox-1.3.4.pack.js\', array(\'jquery\'), \'1.0\', true);
// fancyboxControls needs jquery, jquery-mouseWheel and jquery-fancybox, so we could pass these ids to the third parameter as an array.
wp_register_script(\'fancyboxControls\', get_template_directory_uri() . \'/js/fancybox/fancyboxControls.js\', array(\'jquery\', \'jquery-easing\', \'jquery-mouseWheel\', \'jquery-fancybox\'), \'1.0\', true);
// Everything is registred, just enqueue our last script
wp_enqueue_script(\'fancyboxControls\');
}
}