How do I add a php statement to a jQuery string

You might want to try to use wp_localize_script() to allow your javascript to use data that are normally only available using php. Here is the link in the codex that will help you do what you need:

https://codex.wordpress.org/Function_Reference/wp_localize_script

Another way is to use a php to output your entire javascript code (in a php file, that is, and not a js file). That way you can use php the way you would normally do.

Leave a Comment