1

I have a plugin page, which doesn't have header.php or footer.php. How can I include Wordpress jQuery on this page so I can use syntax like below ?

  jQuery(document).ready(function()
  {
      alert('hello');
  });

At the moment it says:

Uncaught ReferenceError: jQuery is not defined
3
  • Is the plugin page in admin area or in front end? Please provide a bit more details. May 18, 2017 at 12:52
  • 1
    As @VinodDalvi said, this question lacks context. For example why exactly the page lacks calls to header.php May 18, 2017 at 13:57
  • 1
    looks like you are trying to define jquery.min.js, in the header.php of the theme or in the header/footer section when page loads so your script will run Right ? May 18, 2017 at 19:33

2 Answers 2

3

Though uncommon, you can use wp_print_scripts( ['jquery'] ) for explicit output.

Note that you might hit issues with hooks firing in unexpected ways and such. Generally all WP pages on front end should just implement header/footer properly.

2

Use wp_head(); and wp_footer(); if you're putting all html in just one file.

Although I would suggest making custom header for your plugin page. Which will have <head>, <html> and other necessary tags. Same with footer. eg. header-plugin.php and the use get_header('plugin');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.