[英]Jquery accordion menu in wordpress
您能帮我,我写的用于jquery手风琴的javascript代码在哪里写的正确位置,我应该将其放置到file.js并在functions.php,wp_register,wp_enqueue,add_item中通过函数调用吗? 我是这个系统的新手。 非常感谢您的帮助
要将自定义javascript添加到您的网站,您应该查看wp_enqueue_script函数。
您可以在主题的functions.php中或在创建的插件文件中使用它,具体取决于您是否希望它成为主题的一部分。
以下示例来自上面链接的页面,还介绍了使CSS排队的等效功能:
/**
* Proper way to enqueue scripts and styles
*/
function theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.