Let's say I want to run the javascript function launchMyPlugin()
only on post detail pages. At first, I was doing something like this:
myPlugin.js
if ( is_single() ) {
launchMyPlugin();
}
However, this obviously does not work since is_single()
is a php function. What is the right way to do this then? Do I need to add the condition to my .php file instead? Thanks!