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
- to perform the requested action wordpress needs to access your web server. please enter your ftp
- Hide prices and checkout functionality in woocommerce
- How do I exclude plugins from getting automatically updated?
- How can I create a bash install script for my WordPress sites setup (WP+plugins+theme)?
- How to add favicon to my site – in both front end and admin panel
- When can you get current page ID and initialize hooks right after?
- Reordering themes in admin panel
- How get list of updates of wp site?
- How can I list only sites that use a particular theme or plugin?
- Which hook callback has priority if both plugin and theme use the same hook?
- Themes VS Plugins [duplicate]
- Force wordpress to request for FTP Info on theme/plugin install/update
- Can a WordPress plugin or theme contain a virus?
- Override the core function locate_template
- wp_enqueue_script fails to include in footer
- WordPress 5 upgrade: until when is it safe to keep project running in 4.x?
- Installing WordPress only for a separate page – ‘mydomain.com/blog’
- Problem with wp_enqueue_scripts in plugin
- ‘Customize’ button in admin bar for CSS
- Uncode theme content block header ignoring saved changes/not updating?
- Theme and plugin install or update display error in localhost
- Reduce Drop down Menu Width in WordPress
- issues with wp_enqueue_script in my plugin
- Create custom registration form for WordPress Multisite
- Classified ad website : which solutions to use? [closed]
- posts comments goes to trash
- Advanced Custom Field DatePicker [closed]
- jQuery for custom plugin not working with Divi theme
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- What will happen if i deactivate my visual composer plug in? [closed]
- Finding the URL to be used to check if plugin is installed with a theme
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- 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 am I unable to load scripts in head in plugin?
- Theme Custom Pages
- how can I do something on new user registration?
- Making that Admin Bar transparent or a blue color
- how to activate a plugin inside a theme
- wp_dequeue_script for a Plugin
- There has been a critical error on your website – won’t fix no matter what
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- 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
- Override css rules of a plugin within my own theme
- I want to use wordpress themes and plugin to develop website
- Is it possible for a plugin to prevent certain plugins from being installed?
- why the wp_register_script doesn’t work for register_activation_hook
- WP e-Commerce Gold Cart with Plugin Built Into Theme
- Per theme plugins?
- In Multisite Setups, how to update mass sections of sub-sites
- Can’t load the the canges of field groups [duplicate]
- Why won’t wp_enqueue_script work within any plugin file?
- elementor development – custom widget like an inner section widget
- Different theme menu
- Bash script to check available updates
- WordPress fresh installation did not update default plugin and themes to latest version
- How to store a custom theme and update it on other installations
- Link custom post type to page
- Showing different js file for different theme in wordpress customizer api
- Seeking specific WordPress Layout
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- Cron job emails blank
- How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?
- wp_login_form() ignoring login_form action hook
- WordPress core update fails – no issues with plugin updates
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- How to fix On “An unexpected error occurred” message when I click on Add new theme or plugin?
- How to display post by date written (1974) and not date published (today)?
- Images is not showing after migration
- Incentive theme – Getting ’You do not have sufficient permissions’ while trying to install plugins
- Child Theme Changes Are Not Reflecting In Parent Theme
- Input gets deleted/overwritten after changing to different Admin Menu
- Theme specific plugin, how?
- How do I make the selected layout display for all MarketPress pages?
- Plugins enqueuing jquery in head
- Run WP inside a other Site without using frames
- Can’t get custom user meta to show in header
- Breadcrumb is not generating the correct post page url
- Display static pages instead of category, in code
- How to make only selected posts appear on a selected wordpress page
- Theme causing SSL break on chrome
- Install theme as part of a plugin
- Divi Template A Few Questions
- Is there a way to stop the theme and especially plugins listed?
- Am having issues intergrating this api into my wordpress site, any help please?
- wp_enqueue_script doesn’t load JS in plugin
- Prevent primary navigational menu from expanding during page load (WordPress / Astra Theme)