2013-05-16 75 views
1

我有一個表格,用戶將根據健身測試結果填寫表格,例如每分鐘俯臥撐,每分鐘仰臥起坐,2英里跑步時間等。此表單正在提交到自定義模板頁面也很好。然而,我想使用this jquery插件來幫助我驗證我的表單。將jQuery插件安裝到wordpress

如何添加的jQuery庫,這樣到WordPress,所以我可以驗證我的形式

+0

請閱讀有關wp_enqueue_script的http:// codex.wordpress.org/Function_Reference/wp_enqueue_script –

+0

我看了你提供的鏈接。我不知道在哪裏放置代碼 – psycho

回答

0

打開的functions.php並添加以下代碼:

//ad our custom Jquery 
function init_js_scripts() { 
if (!is_admin()) { 
    wp_register_script('jquery', ('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'), false, ''); 
    wp_enqueue_script('jquery'); 

    // load a JS file from your theme: js/theme.js 
    //You will need to create js Folder and put your script in there... 
    wp_enqueue_script('my_cool_script', get_template_directory_uri() . '/js/cool_script.js', array('jquery'), '1.0', true); 
} 
    } 
    add_action('init', 'init_js_scripts');