se this in your functions file:
// Enqueue Scripts
function wpse78227_enqueue_scripts() {
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'wpse78227_enqueue_scripts' );
Next for including that script you need to follow teh below steps:
- Create a new file in your theme for the script (i.e.
jquery.show-hide.js)
- Copy that jQuery function into this new file
- Enqueue the script file as you would any other
This would then give you:
// Enqueue Scripts
function wpse78227_enqueue_scripts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-show-hide', get_template_directory_ui() .
'/js/jquery.show-hide.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'wpse78227_enqueue_scripts' );
Your script file might now be located in /wp-content/themes/your-theme-name/js/jquery.show-hide.js.