Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm just wondering what is the correct way to do it? Add it in via the theme header? If so, what is the proper way to do it? I see a lot of the other current stuff in there using the bloginfo() function.

Thank You!

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

You could tack it into header.php as you suggested (although this is not really the proper way to do it, it is best to use WPs enqueue function as described here).

When do you need these? All the time? You can enqueue scripts and styles to be used all the time, or on an as-needed/per template basis

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

share|improve this answer
    
Thanks. I will only need them for the one page really. –  Brett Mar 14 '11 at 20:32
    
Yeah, you can enqueue each for that specific template then. It would really be the best way to do it. The links everyone provided here are excellent and should help you. An example of the code I used: wp_enqueue_style( "member_css", $voodoo_template_dir . '/scheme/member-template.css', false, "1.0", "all" ); On my members.php template only loads the member-template.css stylesheet for that template –  Rev. Voodoo Mar 14 '11 at 20:37
    
Great thank you! –  Brett Mar 14 '11 at 21:18
    
Since your answer has been marked as accepted, I implore you to edit it to point out that adding the scripts to the header.php file is NOT the recommended way of doing things. –  tnorthcutt Mar 14 '11 at 22:34
    
Done. Monday mornings are kinda rough, that answer wasn't worded as well as it could have been for sure.... –  Rev. Voodoo Mar 15 '11 at 12:13
add comment

Scribu has an excellent article on loading scripts in WordPress. Basically, if you need a script to load on every page, use the following code (blatantly copied from said article):

add_action('template_redirect', 'add_my_script');

function add_my_script() {
    wp_enqueue_script('my-script', plugins_url('my-script.js', __FILE__), '1.0', true);
}

(I removed the part of that snippet that expresses a dependency on jQuery). I suggest you read that whole post - it's very educational.

share|improve this answer
    
Thanks for the great info & link! –  Brett Mar 14 '11 at 21:19
add comment

the right way would be using wp_enqueue_script for scripts and wp_enqueue_style for styles.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.