I’m writing a WP plugin that might be called on any page using a simple function call:getDeck(Deck_id)
– and i’d like to add my javascript files on pages where this function is called ONLY, as opposed to having it on every page…
What do I do?
I’m writing a WP plugin that might be called on any page using a simple function call:getDeck(Deck_id)
– and i’d like to add my javascript files on pages where this function is called ONLY, as opposed to having it on every page…
What do I do?
You must be logged in to post a comment.
If your scripts can be printed in the footer add the enqueue to the definition of
getDeck
, with the final argument set totrue
.I.e in your plugin file
The issue here is that you want to be able to call the function on any page. And if you’re distributing the plugin, you will either require users to add code or you should provide a settings page on which the user can choose on which page the file should load.
If you’re developing the plugin for one specific website and you want to add the JS to specific pages, you can do so with
is_page()
: