As the “Error Message” (which is in fact a “doing it wrong”-message) is telling you, you’re using the wrong hook:
Scripts and styles should not be registered or enqueued until the
wp_enqueue_scripts
,admin_enqueue_scripts
, orlogin_enqueue_scripts
hooks.
Just read about hooks, wrap your code in a callback and then register it properly on one of the three hooks (hint: the one that fits).
Related Posts:
- Pass $this to function nested in another public function of the same class
- Dequeue / Deregister script and replace it with a new plugin
- dequeue not work
- How to avoid redefining requirejs in plugin when another plugin also uses requirejs
- React JSX in WordPress Plugin Development
- Use wp_enqueue_scripts from included php file
- Enqueue script: link not working in page source
- Edit all $wp_scripts at once to $in_footer = false
- Edit all $wp_scripts at once to $in_footer = false
- plugins_url not returning correct directory
- How do I keep children of certain parent menus expanded by default on a sidebar?
- Enqueue scripts in the footer
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- How can I position ShareThis buttons manually when using the plug-in? [closed]
- How to require users to login when not logged in
- Error when using plugin QuickCache with plugin Mobile Smart ? [closed]
- Does WP delete deprecated plugin/theme files on plugin/theme upgrade?
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- Create shortcode to echo javascript
- Is there any hook for theme activation ? or something similar?
- How to use get_template part in the plugin?
- How can I use get header from within my plugin?
- How do I find out what is in control over a certain part of a website?
- “No Add Button” for me to customize my WordPress with themes and pluggins
- Is there a loading priority for login_enqueue_scripts?
- How do I combine a theme with a plugin
- How can I list all installed plugins/themes/versions from CLI/API?
- My single.php page does not show the related data to the post which is clicked
- Where are theme codes located for WordPress?
- Overwrite category head title
- Basic gallery plugin suggestion [closed]
- Is there a way to get plugins and themes not built for multisite to work on a network subsite?
- How to check if my wordpress websiste is nulled or not?
- Why does my file_exist check fail?
- Remove specific plugins and themes from the Dashboard->Updates page [duplicate]
- Create a single website with 3 theme options in wordpress
- using do_shortcode
- Why am I unable to load scripts in head in plugin?
- Create custom pages with a plugin
- Deactivate JS Script in Plugin Shortcode
- How to write “alt” tag in image for wordpress code?
- Does heavy theme and plugins affect server’s response time? [closed]
- How to protect WordPress from security scanner [closed]
- How to load different homepage on Mobile.?
- Remove / overwrite some functions in buddypress.js
- How to get menu location in wp_update_nav_menu hook
- Proper way to use plugin functions in functions.php
- How to activate a plugin on the activation of a theme?
- Theme Custom Pages
- Use different single.php file based on condition
- how can I query all wordpress users of a blog
- how can I do something on new user registration?
- WordPress plugin won’t show on some themes
- Register google jquery gets overwritten by plugin
- Making that Admin Bar transparent or a blue color
- Which wordpress theme is compatible Optima Express theme (real estate inventory) plugin?
- How to Include File from Plugins into Template?
- how to activate a plugin inside a theme
- how remove font to increase site speed load
- Add type to enqueued script inside plugin
- How to execute plugin and theme updates from a web hook / endpoint?
- wp_dequeue_script for a Plugin
- Use $variable from file1.php in file2.php (different file paths)
- There has been a critical error on your website – won’t fix no matter what
- How to make a dynamic css class whose name changes every visit to confuse scraper
- Is it possible not to load theme on a specific page in wordpress?
- How to get theme’s info from wordpress.org/themes using api.wordpress.org?
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- I receive taxonomy id
- To perform the requested action, WordPress needs to access your web > server
- How to find the list of custom post type where logged in user is author
- What is the purpose of WP_CONTENT_URL?
- How to translate WP Blog (search, category etc.)?
- Theme My Login Shortcode Doesn’t Return Anything
- issue in wp_localize_script
- Include Minit plugin in theme [closed]
- How do I set up XAMPP to allow me to download plugins and themes?
- How to extract a .wp-env.json or composer.json containing plugin versions from a production website?
- How do I add a plugin dependency to my customized theme?
- Moving FB comments at the end of page
- Custom plugin – load enqueue only for this plugin
- How to include files relative to a file’s directory
- How can I use my custom wordpress theme on two websites? [closed]
- How to remove products-links after the product title using remove_action
- How Do I Uninstall a Current WordPress Theme and Install a Fresh Theme
- why need theme,if page builder is there in wordpress [closed]
- Licensing options for WordPress Plugins
- What is it and from where it is loaded?
- speed up pagination for huge database
- Can I filter a function created by a theme or a plugin?
- How I update WordPress theme and plugins
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- Override css rules of a plugin within my own theme
- Deregister scripts from plugin
- Overwrite add_image_size defined by theme
- I want to use wordpress themes and plugin to develop website
- Custom CSS not being added by plugin
- Don’t load the theme for a page FROM a plugin EDITED
- Extending a theme: build new features as plugin or core modules?
- Blocking Plugin Css to load custom in template directory