WordPress可以通過手動嵌入式js和樣式嵌入來獲得挑剔。注入它們的正確方法是add_actions
到init
,print_scripts
和print_sytles
。以下,或者類似的東西添加到您的Functions.php
:
// register scripts
if (! function_exists(register_scripts){
function register_scripts() {
wp_deregister_script('jquery');
wp_register_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js');
}
}
add_action('init', 'register_scripts');
//print the now registered scripts
if (! function_exists(print_scripts){
function print_scripts() {
wp_enqueue_script('jquery');
}
}
add_action('wp_print_scripts', 'print_scripts');
// do the same for css
if (! function_exists(print_styles){
function print_styles() {
wp_register_style('stylesheet', 'path to css'.stylesheet.css); //bloginfo(url); or something like it to obtain your path
wp_enqueue_style('stylesheet');
}
}
add_action('wp_print_styles', 'print_styles');
它多一點的工作,但確保腳本和樣式得到正確插入,並在同一時間的wordpress選擇這樣做......
如果這是導致你的問題,我不積極,但它是一個很好的開始。
你可以發佈一些其他包括? CSS如何「崩潰」?你有多個jQuery包含? – barfoon
什麼形式? 「css崩潰」是什麼意思?我們需要看到相關的代碼(在問題中,而不是外部鏈接) –
爲什麼你包括在線jQuery庫...而是下載jQuery庫並使用它.. – diEcho