Why is jQuery so great?
- It has a wide range of plugins available for various needs.
- It is easy for designers and developers to learn.
- It’s included with WordPress.
jQuery is so popular that WordPress automatically comes with it loaded. (This started in WordPress 3.8.1.) Just because WordPress comes with jQuery, however, does not mean it is ready for use right out of the box. If you are using or creating a theme where jQuery is not called yet, you will have to do a couple things before you can start utilizing it.
How to add jQuery functionality to your WordPress theme
While WordPress comes with jQuery, you still have to make sure that you are actually adding it to your theme so you can use it. This is done by enqueueing the script and then specifying and adding to a file with the jQuery code snippets. This can be done in two simple steps.
First, make your script file and put it in the theme folder
js folder to keep things organized. For this example, I’ll add a file called
custom_scripts.js, which is placed in a subfolder of the theme folder. The path would look like this:
mytheme/js/custom_script.js. With jQuery, the file extension will have a
Below is an example of a simple jQuery script that could go into the
custom_script.js file. This is a good way to test things out.
« How to remove “Archive:”, “Category:” etc. pre-title inserts in Archive Titles
Beginners Guide: Implement jQuery Scripts into WordPress Websites »