简体   繁体   English

WordPress的jQuery手风琴菜单

[英]Jquery accordion menu in wordpress

Can you help me, where is the right place to put my javascript code for jquery accordion in wordpress, that i write, should i place it to file.js and call by function in functions.php , wp_register, wp_enqueue, add_item ? 您能帮我,我写的用于jquery手风琴的javascript代码在哪里写的正确位置,我应该将其放置到file.js并在functions.php,wp_register,wp_enqueue,add_item中通过函数调用吗? I'm newbie in this system . 我是这个系统的新手。 Thank you very much for your help 非常感谢您的帮助

To add custom javascript to your site you should look at the wp_enqueue_script function. 要将自定义javascript添加到您的网站,您应该查看wp_enqueue_script函数。

You can use this in your theme's functions.php, or in a plugin file that you create, depending on whether you want it to be a part of your theme or not. 您可以在主题的functions.php中或在创建的插件文件中使用它,具体取决于您是否希望它成为主题的一部分。

The following example is from the page linked above and also covers the equivalent function for enqueuing CSS: 以下示例来自上面链接的页面,还介绍了使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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM