views:

212

answers:

2

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.

+1  A: 

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

<script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
<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)

Nocturne
I prefer <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> but whatever floats your boat. You don't need FTP access... there's in editor in wp-admin.
Mark
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.
Nocturne
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()
wavyGravy
Curse! That didn't work either.
wavyGravy
A: 

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?

songdogtech
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?
wavyGravy
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...
wavyGravy
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....
songdogtech
Yea worst comes to worst, I'll have to work on a different theme. Thanks for the input.
wavyGravy