374 posts
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 3
  • Collector Level 2
+4 more
_rohan
says
I think you originally meant “TEMPLATEPATH” not TEMPLATE _URL …

Nope, TEMPLATEPATH gives the actual file path – like /nfs/www/httpdocs/ blah blah. Not the www.domain.com type url.

1037 posts
  • Affiliate Level 6
  • Author Level 10
  • Collector Level 4
  • Top Monthly Author
+9 more
ThemeBlvd
says
I think you originally meant “TEMPLATEPATH” not TEMPLATE _URL …
Nope, TEMPLATEPATH gives the actual file path – like /nfs/www/httpdocs/ blah blah. Not the www.domain.com type url.

I know…but I thought it would work in this case. I just looked at wp_enqueue_script() in the codex, and you’re right! ... needs to be a web url.

1 post
  • 7 Years of Membership
  • Collector Level 1
mattyza
says

Hi All, I’d like to comment on the use of the TEMPLATE _URL constant.

As mentioned in my blog post on enqueueing JavaScript in WordPress, I have defined the TEMPLATE _URL constant for use in themes I develop. This is to create a re-usable value and to avoid multiple look-ups.

Adding the following to your theme’s functions.php file will resolve this:

define( 'TEMPLATE_URL', trailingslashit( get_stylesheet_directory_uri() ) );

Alternatively, replacing TEMPLATE _URL with trailingslashit( get_stylesheet_directory_uri() ) in your PHP code will achieve the same effect. :)

I hope this helps, guys.

All the best, Matty.

by
by
by
by
by
by