Support » Plugins » Hacks » how to use WordPress functions in js file?

  • Resolved danixland


    Hello everybody,
    I am developing a theme, and inside a javascript file I need to access a few WordPress functions like bloginfo()..

    How am I supposed to do this thing?? I use wq_enqueue_script() inside <head> tags to include my js files, but how can I bring WordPress functions to js??

    Thanks a lot in advance…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Sounds like you need wp_localize_script, Otto explains it’s usage well in his blog here.

    Passing parameters from PHP to Javascripts in plugins

    Thanks for your reply Mark…

    I was doing this same thing but in a different way…

    now I just have to learn how to read the parameters I’m passing inside my script…

    thanks a lot again!!

    ok, I can set this thread as solved 😉

    for future reference, after using Otto’s method, explained in detail on Mark’s post, I had to modify the js script this way:

    jQuery(document).ready(function($) {
      var foo =;

    doing so I was able to retrieve the foo variable set up in the array on my header.php…

    thanks a lot, I hope this turns to be useful for others too!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to use WordPress functions in js file?’ is closed to new replies.