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

Answers


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' );

Need Your Help

phonecallTask not working in Windows Phone 8

c# windows-phone-8

PhoneCallTask is not working in Windows Phone 8.

How do I test exceptions and errors using pytest?

python python-2.7 error-handling exception-handling pytest

I have functions in my Python code that raise exceptions in response to certain conditions, and would like to confirm that they behave as expected in my pytest scripts.