Is there a nice way to load a js file based on the post type being viewed?
I have a supplier which has a map on it but I only want the load the js when a single one is being viewed. I load the script in my functions.php file.
Is there a nice way to load a js file based on the post type being viewed?
I have a supplier which has a map on it but I only want the load the js when a single one is being viewed. I load the script in my functions.php file.
You must be logged in to post a comment.
If you hook onto a later action such as
template_redirect
, you should be able to check the query vars to determine if your specific post type is being viewed.Or alternatively like this…
Hope that helps.
you can use this code: