我不知道为什么所有基于 Jquery 的插件在我的 wordpress 主题中都不能正常工作。例如,切换插件或 dw 问题。
这就是我在主题中连接脚本的方式:
在标题中
<?php wp_enqueue_script("jquery"); ?>
<?php wp_head(); ?>
在函数中:
add_action('wp_enqueue_scripts', 'no_more_jquery');
function no_more_jquery(){
wp_deregister_script('jquery');
wp_register_script('jquery', "http" .
($_SERVER['SERVER_PORT'] == 443 ? "s" : "") .
"://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js", false, null);
wp_enqueue_script('jquery');
if ( !is_admin() ) {
function easing()
{
wp_register_script( 'jquery_easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array( 'jquery' ) );
wp_enqueue_script( 'jquery_easing' );
}
add_action( 'wp_enqueue_scripts', 'easing' );
function camera()
{
// Register the script like this for a theme:
wp_register_script( 'camera_min', get_template_directory_uri() . '/js/camera.min.js', array( 'jquery' ) );
wp_enqueue_script( 'camera_min' );
}
add_action( 'wp_enqueue_scripts', 'camera' );
function jquery_ui()
{
wp_register_script( 'jquery_ui-script', get_template_directory_uri() . '/js/jquery-ui-1.9.0.custom.min.js', array( 'jquery' ) );
wp_enqueue_script( 'jquery_ui-script' );
}
add_action( 'wp_enqueue_scripts', 'jquery_ui' );
function fadeSlideShow()
{
// Register the script like this for a theme:
wp_register_script( 'fadeSlideShow-script', get_template_directory_uri() . '/js/fadeSlideShow.js', array( 'jquery' ) );
wp_enqueue_script( 'fadeSlideShow-script' );
}
add_action( 'wp_enqueue_scripts', 'fadeSlideShow' );
}
}