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 enqueuing a script:

wp_enqueue_script('my-script', MY_SCRIPTS."/my-script.js"); 

How to get MY_SCRIPTS const working in this context?

I know this works:

$template_dir = get_bloginfo('template_directory');

But I don't like this approach at all.

share|improve this question
up vote 3 down vote accepted

The value you pass to wp_enqueue_script should be the URL of the script, not the local file path.

wp_enqueue_script('my-script', get_template_directory_uri() . '/my-scripts/my-script.js');
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.