That snippet ‘works’ for me.
Is the script being printed at the bottom of the page? More specifically, does your theme call wp_footer. All themes should, but not all themes do call wp_footer which breaks plugins which rely on it.
For the record – you should not print scripts directly to the page. WordPress has a great API for handling JavaScript enqueing and dependency handling. See this codex page.
You may also find this question helpful too.
Related Posts:
- fix the error : Plugin with id ‘com.android.application’ not found
- How to use classes declared in another plugin?
- Experiences with adding Nonces to the comment form
- How can I allow moderated anonymous contributors to post to my blog?
- Add rewrite rule to permalink structure
- Best way to manage a lot of pages in Wp Admin [closed]
- Finding WordPress sites using my plugins
- Error: “Cannot modify header information”
- WordPress 4.0 Cookie Authentication to avoid nonce error when publishing a post and page
- how to display all posts Custom fields dynamically?
- How to Build a Movie Library in WordPress 3.x
- Nested CPT URLs + Posts 2 Posts
- [Plugin: Posts 2 Posts] How does it work?
- How to Implement “Notice: This theme recommands the following plugin:xyz” in wordpress? [closed]
- Accessing GET variable named ‘error’
- I don’t understand how this parameter works..?
- Cannot login to ADMIN even after changing password in phpmyadmin
- download_url() appears as grey icons
- How can I add an options page for my class based plugin?
- Sending WP posts to external API
- dynamically generating plugin syntax
- wp_create_nonce function doesn’t work inside a plugin?
- Easy Digital Download Sub category
- Events Plugin that works with existing categories?
- How to display more than one instance for a widget?
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- wp_get_post_terms is difference obj model than the one in rest api response
- Prevent duplicate records in plugin table
- How to import multiple language mutations to polylang?
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- Uncaught TypeError: jQuery(…).flipster is not a function in wordpress
- Delete mobile menu button [closed]
- Widgets Scripts don’t load – but load when I reload the page
- How to replace WordPress Media Upload Window with user’s device window?
- Can’t catch enqueued style
- Fatal error can’t activate a plugin [closed]
- Edit External CSS
- How to prevent additional code in functions.php to be removed once there is an update?
- Update a core option from plugin settings page
- How do I pass custom shortcode-extracted variables (taxonomy) into a query function for WordPress RoyalSlider?
- Thesis 2 custom Page
- Display linked articles at the bottom of post (like related posts)
- register_activation_hook() not working as expected
- WooCommerce – set session with new cart item meta when updating cart item quantity [closed]
- Plugin not working & permalink erorr after upgrade to php 7x on Nginx
- Running multiple security plugins
- Opening a JQuery modal window on click of a button with a JQuery plugin
- Can I clone plugin folder to another directory so that I don’t have to reinstall them?
- Woocommerce singe product custom gallery output works just on the first slide
- Correct Plugin File Path
- strange shortcode error: does shortcodes requires any dependency?
- Search by Attachment ID
- Apparent errer when installing plugin
- Issue removing Media Editor Tabs — Duplicate Items
- display link to a custom plugin in admin menu bar
- Creating teams of users in WordPress
- Removing the custom_image_header from wp_head
- Is it safe to use Web Invoice 2.1.0 without SSL?
- A plugin popularity data inside “install new plugin” [closed]
- How to properly replace the_content with the html in a php file?
- Is there a way to make [Table Of Content] plugin while not using revision data?
- How to Add text value in Automatically in this conditions?
- wordpress fcm plugin not working on scheduled posts correctly
- Elementor: How to design Dropdown Select Box Navigation page like Chegg
- Get user edit functions in frontend for site admin
- Critical Error message of WordPress adming
- Clicking custom plugin admin menu redirects to “No Update Required” on live site
- Displaying all the images from all of my articles
- Problem with Date translation in WordPress
- Create new page in wordpress plugin which doesn’t exist
- Use WordPress Plugin without WP head
- Is it possible to pull all featured images from WP database only?
- install / update plugins remotely
- Creating custom “player-objects”
- 500 Internal server error wp_handle_upload_prefilter
- Forum creation with bbpress and front end
- Migrations for plugins, page and theme: looking for a good approach
- Fatal error when activating my custom wordpress plugin
- Media library and Upload media problem
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- Nested DIV’s across functions in PHP, do not seem to work
- How to move WordPress gallery image out of the link?
- I created a custom form in HTML/CSS and now I need it to submit … should I create custom PHP or is there a plugin I can use?
- Restore Category Base
- Problems with installing and deleting plugins
- Need to change contact email depending where user is from
- How to show an image popup when one clicks on an image thumbnail?
- Add page-link after post content. Before plugin
- What method should I use for a sidebar widget that reads latest posts?
- wordpress last all added get meta value by post id
- Visual Composer Data Source?
- WP Offload S3 Lite “Please setup GD or ImageMagick” noticed
- Possible to add “Template” selector to pages? Is Any Plugins are There..?
- How to add a static image inbetween the product tiles on main shoppage woocommerce?
- Plugin download link
- thumbnail_width not working in wordpress most popular post plugin
- Gravity Forms and Gravity View Permissions
- Admin Notice is only localized when displaying the “Plugins” Backend Page
- How to call a logging function from a generic utility plugin from another plguin
- WordPress – How to add an attribute to a plugin inline script tag