2

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.

1 Answer 1

6

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.

1
  • 3
    +1 for encouragement of wp_localize_script. One of the most underappreciated and used WP techniques.
    – tollmanz
    Commented Aug 22, 2011 at 15:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.