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