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 a jQuery floating navbar plugin that works fine when all the code is inserted in the head. However the ammount of code in the head became unmanageable so I put the code in the root directory in a file called sscroll.js.

I have tried to include the file the following ways but they don't work. (No errors are coming up on firebug)

<?php wp_enqueue_script('sscroll', 'sscroll.js', array('jquery')); ?>

<script type="text/javascript" src="sscroll.js"></script>
<script>
$('#sidecontainer').stickyfloat({duration: 400 });
</script>

>

<script type="text/javascript" src="sscroll.js">$('#sidecontainer').stickyfloat({duration: 400 });</script>

>

<script type="text/javascript" src="sscroll.js"></script>

I prefer using the enqueue script, but I'll be happy with anything that works. Any suggestions welcome. Thanks!!!

share|improve this question

1 Answer 1

Use an absolute URL - you say the script is in the root directory, is that the root directory of WordPress? If so;

<?php wp_enqueue_script( 'sscroll', site_url( 'sscroll.js' ), array( 'jquery' ) ); ?>
share|improve this answer
    
Hi DeadMedic - thanks! adding site_url( did the trick! –  user3952 Mar 18 '11 at 11:05

Your Answer

 
discard

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