UPDATE: WordPress newest update has made all calling scripts to be called in the last part. Move any other calls into one. The script below has been updated to reflect this.
There are lots of web pages that explain how to add Jquery to your website but all of them I have found are very extensive and are 10,000 words long. mostly to gain SEO rankings!
So without any more explanation here is the most simplest way to add Jquery to your WordPress website.
Add this to the bottom of your functions.php file which is found in your current theme folder
12345678
function codehaven() { wp_enqueue_style('theme_custom_style', get_template_directory_uri() . '/../codehaventheme/style.css'); wp_enqueue_script('jquery'); wp_enqueue_script( 'script-name', get_stylesheet_directory_uri().'/gtjquery.js', false );}add_action( 'wp_enqueue_scripts', 'codehaven' );
1 2 3 4 5 6 7 8 |
function codehaven() { wp_enqueue_style('theme_custom_style', get_template_directory_uri() . '/../codehaventheme/style.css'); wp_enqueue_script('jquery'); wp_enqueue_script( 'script-name', get_stylesheet_directory_uri().'/gtjquery.js', false ); } add_action( 'wp_enqueue_scripts', 'codehaven' ); |
Then add this code below to a script named gtquery.js in the theme folder.
1 2 3 4 5 |
jQuery(document).ready(function($){ alert("hi"); }); |
If all else fails use this plugin….