2012-12-05 26 views
0

由於某些原因,我的jQuery腳本似乎只在登錄到WordPress時才加載。這裏是頁面: http://www.mcfaddengavender.net/newmg/僅當登錄到WP時jQuery才起作用

正如你所看到的,圖像不是「滑動」英寸然而,如果我登錄並返回到主頁,事情工作正常。下面是我使用jQuery的運行中的代碼的functions.php:

//jQuery - Use Google CDN instead of WP jQuery 
function my_scripts_method() { 
if (!is_admin()) { 
    wp_deregister_script('jquery'); 
    wp_register_script('jquery',  'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'); 
    wp_enqueue_script('jquery'); 
} 
} 

add_action('init', 'my_scripts_method'); 
?> 

任何想法什麼會導致這樣一個奇怪的問題?

回答

0

你是掛鉤在錯誤的地方使用

add_action('wp_enqueue_scripts', 'my_scripts_method'); 

,而不是 '初始化'

相關問題