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
wp_register_script('SliderViewer', '/js/SliderViewer-1.2.js');


however, mydomain.com/js/SliderViewer-1.2.js doesn't exist.

My js is in the ftp at

thewebsite -> wp-content -> themes -> BLANK-Theme -> js

What's the path of that? Thanks-

share|improve this question
up vote 3 down vote accepted

You're registering/enqueueing your script wrong. You should register/enqueue in your theme's functions.php file instead of inside the header/page.

Also, you need to use your theme's directory ... which will be along the lines of mydomain.com/wp-content/themes/BLANK-Theme/js/SliderViewer-1.2.js.

Use this code in functions.php:

function my_scripts_enqueue_method() {
        get_template_directory_uri() . '/js/SliderViewer-1.2.js'
add_action( 'wp_enqueue_scripts', 'my_scripts_enqueue_method' );

This will enqueue and register your script, and ensure that you're using the appropriate directory for your theme in the process.

share|improve this answer
I'm just trying to do this for ONE page though. – Jacksonkr Apr 9 '12 at 21:30
For one page, then, you should really be using a custom page template. But the guidance on referencing the script in your call to wp_enqueue_script() stands. – EAMann Apr 9 '12 at 21:33
This all works (accepted), but now I'm curious.. What was the problem with using wp_register_script? I like to be enlightened. – Jacksonkr Apr 9 '12 at 21:37
No problem, just unnecessary. wp_enqueue_script() will automatically register the script for you. The biggest change was using get_template_directory_uri() to build the path to your script. – EAMann Apr 9 '12 at 21:39
but you register with this snippet on all pages, backend and frontend. Use Conditional Tags, like is_admin() and is_singular() to load only on page, there you will use this script. – bueltge Apr 10 '12 at 7:16

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.