2014-12-04 22 views
0

我想添加一個jQuery完整日曆到我的wordpress插件。默認情況下,wordpress包含jQuery的這些小部件:http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Scripts_Included_and_Registered_by_WordPress但我期望的小部件:http://fullcalendar.io/不是默認jQuery安裝的一部分。Wordpress添加jQuery完整日曆支持wordpress

有人可以請詳細說明如何作爲我的插件的一部分,我可以添加對jQuery完整日曆的支持嗎?此問題與我在此處詢問的另一個問題有關:"undefined is not a function" when I add a WordPress plugin

問題的背景是,在二十四個主題下,我的代碼在插件中工作正常。在不同的主題 - OptimizePress - 代碼不起作用,我認爲這是因爲jQuery被OptimizePress加載,因此不包括我日曆的jQuery支持。

請幫忙!

回答

1

將此添加到您的孩子主題的functions.php文件中。

function fullcalendar_jquery_enqueue() { 
    wp_register_script('fullcalendar', "http//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.3/fullcalendar.min.js", false, null, true); 
    wp_enqueue_script('fullcalendar'); 
} 
add_action("wp_enqueue_scripts", "fullcalendar_jquery_enqueue", 11); 

function load_styles() { 
    wp_register_style('fullcalendarcss', 'http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.3/fullcalendar.min.css'); 
    wp_register_style('fullcalendarprintcss', 'http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.3/fullcalendar.print.css'); 
    wp_enqueue_style('fullcalendarcss'); 
    wp_enqueue_style('fullcalendarprintcss'); 
} 
add_action('wp_print_styles', 'load_styles'); 
+0

我已經做到了 - 但它仍然有同樣的錯誤,因爲我在證明:http://stackoverflow.com/questions/27180306/undefined-is-not-a-function-when-i- add-a-wordpress-plugin – RenegadeAndy 2014-12-04 18:47:33

+0

我看到一些與OptimizePress主題衝突的類型。你能否啓用你將要使用的主題並將我鏈接到你的網站?我可以在那裏弄清楚。最近我一直在處理類似的問題。 – hawkeye126 2014-12-04 18:50:40

+0

是的,當然我可以 - 但我寧願鏈接私人給你 - 不知道如何開始在stackoverflow上的'對話',而不是繼續評論這個線程,直到它提供了一個? – RenegadeAndy 2014-12-04 18:52:05