0

Would anyone know how to get the jQuery api going with Wordpress? I know that you can add an action in the functions template but this particular theme template isn't letting me add it.

2
  • what type of error are you running into? Commented Apr 25, 2009 at 2:05
  • I don't see any errors whatsoever. It just doesn't start up. Can't seem to figure out how to get the dom going. I tried testing out a simple js function and it doesnt even appear. Commented Apr 25, 2009 at 17:27

2 Answers 2

1

The easiest way to add jQuery is to use the Google Ajax libs API

<script src="http://www.google.com/jsapi"></script>
<script>
  google.load("jquery", "1");
</script>

Add these lines in the <head> section of your main template page, and you should be able to use jQuery right away.

(I believe this would require you to have FTP access to your blog or at least access to the theme-editor such that you can edit the main PHP theme pages themselves)

Sign up to request clarification or add additional context in comments.

3 Comments

I prefer <script type="text/javascript" src="ajax.googleapis.com/ajax/libs/jquery/1.3.2/…> but whatever floats your boat. You don't need FTP access... there's in editor in wp-admin.
I prefer my approach for a number of reasons. (1) It automatically selects the highest version, for instance, in my case it would automatically select 1.3.2 when I enter 1 (2) It is clearer when you're adding a number of other JS libs like prototype, YUI etc -- with the "ajax.googleapi's" URL the library name itself is difficult to read immediately. (3) Arguably faster loading: Lesser characters == lesser bytes.
Thanks for reading my first post! I'm pulling the api from google. I know it works with any old template cause it works with the default template. I think I have to declare this in the beginning of my script: $jQuery.noConflict()
0

What kind of errors are you seeing? Are you also calling <?php wp_head(); ?> in the header? Are you also linking < wp_enqueue_script('jquery'); ?> , which also loads jquery?

4 Comments

Yea I'm calling the header template. This ditty is in my functions.php template: add_action( 'wp_print_scripts', 'custom_add_javascript' ); function custom_add_javascript( ) { wp_enqueue_script( 'functions', '/wp-content/plugins/functions.js', array( 'jquery' )); } I'll add that method to the header and see what happens. I really appreciate it man. Love this site already. It'll work with the other defualt template. Is there something else that I'm not doing right?
I'm not seeing no errors whatsoever. The other thing is I can't even do a simple js function. Sucks cause the author of the theme locked out his forum. Nigh...
Sounds like the theme might be loading jquery more than once and you're getting conflicts. I've found that many Wordpress themes are hacked together and the authors aren't clear about what they are doing. I'd find another theme or cruise the Wordpress support forums....
Yea worst comes to worst, I'll have to work on a different theme. Thanks for the input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.