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 have some Jquery links in my header. First off I am probably not using the proper wordpress function to do this. Right now on my site the code that is below is not working. These links aren't there, but in my ftp directory they exist. I am not sure what I am doing wrong? I can link to the live site if needed.

<link type="text/css" href="http://fiftyfity.com/wp-content/themes/fiftyfityNew/jQuery-ui-1/css/pepper-grinder/jquery-ui-1.8.17.custom.css" rel=stylesheet />
<script src="http://fiftyfity.com/wp-content/themes/fiftyfityNew/jQuery-ui-1/js/jquery-1.7.1.min.js"></script>
<script src="http://fiftyfity.com/wp-content/themes/fiftyfityNew/jQuery-ui-1/js/jquery-ui-1.8.17.custom.min.js"></script>

and here is the code before output

 <?php $url = content_url();?>
<link type="text/css" href="<?php echo $url; ?>/themes/fiftyfityNew/jQuery-ui-1/css/pepper-grinder/jquery-ui-1.8.17.custom.css" rel="stylesheet" /> 
<script src="<?php echo $url; ?>/themes/fiftyfityNew/jQuery-ui-1/js/jquery-1.7.1.min.js"></script>
<script src="<?php echo $url; ?>/themes/fiftyfityNew/jQuery-ui-1/js/jquery-ui-1.8.17.custom.min.js"></script>
share|improve this question
    
When I go to fiftyfity.com/wp-content/themes/fiftyfityNew/jQuery-ui-1/js/… I get an http auth prompt. If that's the real address and not FPO, I'm guessing that's your issue. Those files will need to be publicly accessible –  Matthew Boynes Feb 21 '12 at 0:30
    
How would I go about keeping my site private while I test it. I was just using .htaccess I didn't think that should make the links not work. –  Anders Kitson Feb 21 '12 at 0:51
    
There are a number of plugins to do this, which is almost certainly the path of least resistance. –  Matthew Boynes Feb 21 '12 at 1:04
add comment

1 Answer

The proper way to include styles and scripts is with the wp_enqueue_script() and wp_enqueue_style() functions. The codex pages on both of these functions covers how to use them very well. Basically you just need to give the script the source (do it relative to your current PHP file) of the script/style and a slug to reference it by. If you're enqueueing conditionally, then you should look at wp_register_script() and wp_register_style() as well.

share|improve this answer
    
I will try this. My wordpress just started acting up with something else, so I am reinstalling. –  Anders Kitson Feb 21 '12 at 0:52
    
I really couldn't figure this out, could you explain a little bit. –  Anders Kitson Feb 21 '12 at 4:41
    
What part of it is confusing you? If it's complicated, it may be served with a better question...I know implementation of the enqueues has been hashed and rehashed dozens of times on this site, have you tried looking at any of those? –  m0r7if3r Feb 21 '12 at 11:02
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.