1
我有多個JavaScript文件。我怎樣才能通過wp_register_script將這些添加到wordpress中?我可以如何通過wp_register_script添加多個javascript?
function wptuts_scripts_with_jquery() {
wp_register_script('custom-script', get_template_directory_uri() . '/js/custom-script.js', array('jquery'));
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script('custom-script');
}
add_action('wp_enqueue_scripts', 'wptuts_scripts_with_jquery');
重複相同的多個腳本,你不能在一個添加多個呼叫AFAIK。 – elclanrs
謝謝你的回答,但我不清楚你的答案。你能舉個例子嗎? – Alamin
您必須爲要添加的每個腳本重複執行'wp_register_script'和'wp_enqueue_script'。 – elclanrs