WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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


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

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

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

share|improve this answer

Your Answer


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.