你不可能<script>
PHP中类似的元素。要么将它们从PHP分隔符中去掉(<?php ?>
) 或使用wp_register_script()
和wp_enqueue_script()
在WordPress中获取脚本。
Update
如何将wp\\u enqueue\\u script()与多个脚本一起使用?
wp_register_script( \'jquery-1.8.2\', get_template_directory_uri() . \'/scripts/jquery-1.8.2.min.js\' );
wp_register_script( \'contact\', get_template_directory_uri() . \'/scripts/contact.js\' );
wp_register_script( \'easing-1.3\', get_template_directory_uri() . \'/scripts/jquery.easing.1.3.js\' );
wp_register_script( \'carousel-2.0.0\', get_template_directory_uri() . \'/scripts/jsCarousel-2.0.0.js\' );
wp_register_script( \'starter\', get_template_directory_uri() . \'/scripts/starter.js\' );
wp_enqueue_script( \'jquery-1.8.2\' );
wp_enqueue_script( \'contact\' );
wp_enqueue_script( \'easing-1.3\' );
wp_enqueue_script( \'carousel-2.0.0\' );
wp_enqueue_script( \'starter\' );
然后在
starter.js
可以放置的脚本:
$(document).ready(function() {
$(\'#carouselv\').jsCarousel({ onthumbnailclick: function(src) { alert(src); }, autoscroll: true, masked: false, itemstodisplay: 3, orientation: \'v\' });
$(\'#carouselh\').jsCarousel({ onthumbnailclick: function(src) { alert(src); }, autoscroll: true, circular: true, masked: false, itemstodisplay: 3, orientation: \'h\' });
$(\'#carouselhAuto\').jsCarousel({ onthumbnailclick: function(src) { alert(src); }, autoscroll: true, masked: true, itemstodisplay: 5, orientation: \'h\' });
});