Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8415969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:36:16+00:00 2026-06-10T01:36:16+00:00

I read the Codex and a few blog posts about using jQuery in WordPress,

  • 0

I read the Codex and a few blog posts about using jQuery in WordPress, and its very frustrating. I’ve got as far as loading jQuery in functions.php file, but all of the guides out there are crappy because they assume you already have a ton of WordPress experience. For instance, they say that now that I’m loading jQuery through the functions.php file, now all I have to do is load my jQuery.

How exactly do I do this? What files, specifically, do I add code to? How exactly do I add it for a single WordPress page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:36:17+00:00Added an answer on June 10, 2026 at 1:36 am

    I know what you mean about the tutorials. Here’s how I do it:

    First you need to write your script. In your theme folder create a folder called something like ‘js’. Create a file in that folder for your javascript. E.g. your-script.js. Add your jQuery script to that file (you don’t need <script> tags in a .js file).

    Here is an example of how your jQuery script (in wp-content/themes/your-theme/js/your-scrript.js) might look:

    jQuery(document).ready(function($) {
      $('#nav a').last().addClass('last');
    })
    

    Notice that I use jQuery and not $ at the start of the function.

    Ok, now open your theme’s functions.php file. You’ll want to use the wp_enqueue_script() function so that you can add your script whilst also telling WordPress that it relies on jQuery. Here’s how to do that:

    add_action( 'wp_enqueue_scripts', 'add_my_script' );
    function add_my_script() {
        wp_enqueue_script(
            'your-script', // name your script so that you can attach other scripts and de-register, etc.
            get_template_directory_uri() . '/js/your-script.js', // this is the location of your script file
            array('jquery') // this array lists the scripts upon which your script depends
        );
    }
    

    Assuming that your theme has wp_head and wp_footer in the right places, this should work. Let me know if you need any more help.

    WordPress questions can be asked over at WordPress Answers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've just read a few posts on hiding Silverlight code in some way. Main
I read through a few of the discussions about the Towers of Hanoi problem.
I'm using jQuery to slidedown and reveal content on my page after a read
Based on a few posts I've read concerning version control, it seems people think
I need to read some Scala code (starting from a few hours ago), I
I have been working on this frustrating bug for a few days now and
I just read a blog post that explains MVC with a banking analogy. I
I recently read an interesting blog post on Anders Hejlsberg's arguments against AOP. The
I read a few lines of code here where it looks to me like
I've read about Orto, a Java virtual machine that runs on Javascript, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.