Have implemented a site in wordpress with 5 static pages besides the usual blog pages that are accesible through the nav menu. Now each of the page has its own jquery animations.
Since I want to write the animations code for all pages in a single file I want to get the page name in javascript and then switch to the proper animation function for that page. How to do this?
If you have access to your WordPress template, you may output the current page’s ID with the
the_ID()template function: http://codex.wordpress.org/Function_Reference/the_IDIf you put this in your <head>, you could access the page ID in JavaScript afterwards:
An alternative: The default theme Twenty Ten assigns a class “page-id-xx” to the <body> element by default. If your current theme does something similar, you could look for this class like this: