Adding Jquery Code to WordPress

For this example we are going to use a script from a sticky menu

First, add your script to a .js file located in your theme and make sure you wrap the code with the first and last lines:

Next, add the following to your functions.php file

You can change “my_assets” to whatever you want to call the functions.
You can change “sticky-nav” to whatever you want to call the script.
Make sure you update the directory path to the path of your above .js file.
Leave “true” as is to call the script in the footer or change it to false to call it in the header.

Leave a Reply