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

Are there any WordPress specific Javascript functions that could be used as helpers when writing custom code?

I am thinking specifically of one that would pull back the base URL of your install, but any helper functions built into WordPress would be nice to know.

share|improve this question
up vote 6 down vote accepted

WordPress installs with a number of libraries/classes/plugins/etc that you can enqueue and use.

For base url specifically, or any vars in general you need to access from javascript, use the api php functions, then pass it to your javascript via wp_localize_script.

share|improve this answer
+1 for encouragement of wp_localize_script. One of the most underappreciated and used WP techniques. – tollmanz Aug 22 '11 at 15:18

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.