trouble importing jquery into wordpress
i have a really annoying problem with wordpress built-in jquery. I have read dozen of articles on the subject of properly registering and calling registered jquery scripts using the functions.php (the code is shown below), but it can't seem to work anyway I try it. Can you please explain to me what did I do wrong, I checked every file path that is hooked to wp_register_script, wp_head in header.php is in place, spelling is correct... I cannon think of the possible reason why none of the jquery plugins listed below won't work on my page, it's frustrating. Here is the link to my website, if it could help you (http://yuagro.eu.pn/wordpress). Many thanks.
// REGISTROVANJE JQUERY BIBLIOTEKA U WORDPRESSU
<?php
function jquery_biblioteke() {
wp_register_script( 'sticky-nav', get_template_directory_uri() . '/js/jquery.sticky.js', array('jquery') );
wp_register_script( 'basic-slider', get_template_directory_uri() . '/js/bjqs-1.3.min.js', array('jquery') );
wp_register_script( 'modern-ticker', get_template_directory_uri() . '/js/jquery.modern-ticker.min.js', array('jquery') );
wp_register_style( 'modern-tickerjs', get_template_directory_uri() . '/js/modern-ticker.js', array('modern-ticker') );
wp_register_script( 'easySlider', get_template_directory_uri() . '/js/easySlider1.7.js', array('jquery') );
wp_enqueue_script('sticky-nav');
wp_enqueue_script( 'basic-slider' );
wp_enqueue_script('modern-ticker');
wp_enqueue_script('modern-tickerjs');
wp_enqueue_script('easySlider');
}
add_action( 'wp_enqueue_scripts','jquery_biblioteke');
?>
我检查了你的链接,检查控制台,它说'jQuery没有定义',你有包括jQuery库即wp_enqueue_script('jquery');
嗯,我从来没有注册过它们,只是将它们与路径一起排队,就像这样:
<?php
function jquery_biblioteke() {
wp_enqueue_script( 'sticky-nav', get_template_directory_uri() . '/js/jquery.sticky.js', array('jquery') );
wp_enqueue_script( 'basic-slider', get_template_directory_uri() . '/js/bjqs-1.3.min.js', array('jquery') );
wp_enqueue_script( 'modern-ticker', get_template_directory_uri() . '/js/jquery.modern-ticker.min.js', array('jquery') );
wp_enqueue_script( 'modern-tickerjs', get_template_directory_uri() . '/js/modern-ticker.js', array('modern-ticker') );
wp_enqueue_script( 'easySlider', get_template_directory_uri() . '/js/easySlider1.7.js', array('jquery') );
}
add_action( 'wp_enqueue_scripts','jquery_biblioteke');
?>
wp_enqueue_script('jquery');
把这添加到你的WordPress的功能之上
链接地址: http://www.djcxy.com/p/61204.html上一篇: WordPress的缓存错误
下一篇: 麻烦导入jQuery到WordPress