tags:

views:

45

answers:

3

Can you import jquery into wordpress when you're not using <?php wp_head(); ?>

i'm just beginning with wordpress and didnt include that in my theme, when i add it now it meses some things up and since i only have to add 1 more thing with jquery i dont want to do the hassle of fixing those things, so i just need to add jquery without the the tag. Any ideas?

A: 

You can manually add jQuery from the Google CDN like this in header.php, above an other calls to jQuery libraries:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;

But realize that not using wp_head in your theme means you will need to manually add links to JS and CSS files for most plugins, as they hook into WP via wp_head and sometimes get_footer, too.

If things don't work right, use Firebug with Firefox to determine what JS is loading and if there are conflicts and errors.

songdogtech
Yes i know, i was making a website for a friend, and started to get intrested in wordpress while i was coding it, by now i'm totally addicted to it and plan to learn it all the way but for now, i only need to add 1 more thing and then its finished so dont really want to go through all the hassle now, and start something new, doing it the right way., ty btw for the answer
vincent
@vincent Check out StackExchange's new [WordPress Answers](http://wordpress.stackexchange.com/) site. I lot of great WordPress questions and answers.
Chris_O
A: 

Use the wp_enqueue_script() function. It's best to use this and let wordpress worry about including the jquery scripts so that you don't end up having the themes/plugins/whatever each including their own versions.

http://codex.wordpress.org/Function_Reference/wp_enqueue_script

jay.lee
A: 

i'm just beginning with wordpress and didnt include that in my theme, when i add it now it meses some things up and since i only have to add 1 more thing with jquery i dont want to do the hassle of fixing those things, so i just need to add jquery without the the tag. Any ideas?

I would highly recommend that you keep <?php wp_head(); ?> not having wp_head will cause more problems down the road. For example, your friend will not be able to use most plugins.

If you want to use Googles jQuery you just need to de register WordPress's jQuery:

if( !is_admin()){
   wp_deregister_script('jquery'); 
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"), false, '1.4.2'); 
   wp_enqueue_script('jquery');
}
Chris_O