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"></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)
Nocturne
2009-04-25 02:19:39
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
2009-04-25 02:49:56
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
2009-04-25 06:46:53
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
2009-04-29 02:25:55
Curse! That didn't work either.
wavyGravy
2009-04-29 02:26:29
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
2009-04-25 16:20:08
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
2009-04-25 16:43:30
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
2009-04-25 16:45:26
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
2009-04-26 17:22:29
Yea worst comes to worst, I'll have to work on a different theme. Thanks for the input.
wavyGravy
2009-04-29 02:24:33