You can’t enqueue because wp_loaded is too early.
To enqueue scripts and styles, you need to do it on the wp_enqueue_scripts type hooks, but because your exiting on wp_loaded, none of those hooks have fired yet.
Additionally, you need to have the necessary function calls in the template for it to enqueue them into, such as wp_head or wp_footer, otherwise there is no opportunity to generate the script and link tags
So your options are:
- use a later hook than
wp_loadedthat happens after the scripts have been enqueued - include the scripts manually inline
Related Posts:
- Using register_activation_hook in classes
- Custom plugin: Trying to show saved data on frontend
- How to set a custom path, for ajax image upload folder in admin?
- action hook wp_head higher priority as all other plugins/hooks
- How to call function at the bottom of post using plugin?
- Adding widgets to my plugin page instead of WordPress dashboard
- Adding function to Genesis genesis_header [closed]
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- using filter and hook inside class
- get Woocommerce product format json for WP_Query
- Register/enqueue scripts only on certain admin pages
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- Add Imports to Existing WordPress Import Map
- error_log() output for print_r() appearing on page
- Check php version before theme activation
- Fatal error: Call to undefined function plugin_dir_path()
- How to make WordPress plugin check for database changes and then do something?
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- How to use copy() function and paste file in /wp-content/themes directory
- Use composer to load custom classes [closed]
- wordpress custom endpoint multiple params
- Is $hook a global variable in WordPress
- allow user to select pages from dropdown in my plugin
- Am I not understanding plugins?
- Page Reloads Before AJAX Request Finishes
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Insert array data on plugin activation
- Same log message keeps on printing to debug.log file thousand of times
- Append HTML Using Shortcode
- Create onClick Event to Re-load a Widget
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to select the contents in the text view textrea in wp_editor?
- Trying to build simple deposit code that hooks into woocommerce
- Add a product to checkout via form
- user_profile_update_errors hook not executing
- How to auto fetch customer details in Woocommerce in checkout page
- Can’t upload image using media_sideload_image
- I want to add custom add to cart link [closed]
- Execute long and heavy processes
- Font Awesome changing default WordPress Font
- Should `wp_login` be used since it’s deprecated?
- Download full html page with CSV export plugin
- How to use a custom hook
- How to hook code to show after the_content?
- Run a code only on theme activation only during first activation
- Theme not calling Jquery properly
- Usage of call back function of add_meta_box()
- WordPress redirect redirecting too many times or not at all
- how to save checkbox data for custom setting?
- How do I add $_SESSION[”] to my wordpress page?
- How to Schedule Cronjobs for start of every month and year
- Get user custom field value on function.php
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Removed jQuery script from header.php , any problems?
- Dynamically Generate Functions and Hooks
- How can I get plugin meta data without knowing the plugin folder?
- calling admin-ajax.php from admin-ajax.php
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- How does add_option() function enable action hooks to fire right after actiavtion?
- save_post trigerred twice
- Create plugin with custom page and template caused an error `Call to undefined function get_header()`
- Settings API form – submit with AJAX
- Wp_Schedule_Event every few minutes doesn’t work
- Submit remote form to wordpress REST API and save data to custom post type
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- Looping through and combining calls to Woocommerce REST API
- Should I use wp_cache in my plugin to make it faster?
- How to import woocommerce custom fields data into another site?
- Add a custom link to each image in WordPress gallery
- How to access this jQuery/AJAX data in a PHP file/WordPress plugin
- post_exists stops working in a scheduled event
- register dependency css and js inside a plugin class
- When I create a new custom post type, it replaces the old post type
- Add class to all meta boxes for a custom post type
- Add .php to end of all WordPress Pages (multisite)
- PHP get_category() function redeclared
- Getting Member Data From WhishList Member on Register
- I’m writing my first plugin and my echo output is showing up on every page of my wordpress installation
- global $post inside plugin query messes up every new post page in wp-admin
- wp_query (or hook) posts by date (id) in array then set post_type
- Chosen Select jquery Not Working in Plugin
- PHP calling function within a class
- Save data of select list after clicking save
- Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?
- Can’t remove menu items added by plugin
- Issues separating my Plugin pages into different files
- How to hide Ads From Certain Categories?
- How do I change the Go To Categories link in the term_updated_messages
- Custom field fetch error on woocommerce pdf invoice
- Displaying custom meta box value in a custom post page
- how to check elementor is widget is active or loaded
- Create a custom plugin with dynamic child pages listing database records
- Is there a hook that I can use when a fatal error occurs?
- Is there a way to pull remotely generated XML, process it, and display it on a Managed WordPress page?
- Cannot Access ACF Field Values via my Plugin