1

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

But I don't like this approach at all.

1 Answer 1

3

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.