简体   繁体   中英

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 ? 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.

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.

The following example is from the page linked above and also covers the equivalent function for enqueuing 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' );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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