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_loaded
that 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?
- When to use Exceptions vs Error Objects vs just plain false/null
- WordPress and event-driven programming – what is it about?
- WordPress URL Rewrite not working
- Detect a focus on wp_editor
- How to remove a metabox from menu editor page?
- simple wordpress ajax plugin not working when not logged in
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Utilize WP-CLI from inside WordPress, not SSH
- Saving metabox repeatable fields
- how to create and show sessions in word press?
- do not show web page section when using advanced custom fields pro
- How to get all existing post types
- New Plugin Review
- Create custom blocks for bootstrap
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Do my defines need to be unique?
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- woocommerce subscriptions – get expiration date [closed]
- Delete a WordPress transient from a shortcode on Page/Post update
- Remove an action hook within a Class
- Plugin CSS not enqueing
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- Edit incorrect password message WordPress
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- How to call plugin function per site in a multisite?
- Error in custom php function doesn’t exist
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- How wp-cron can run in background if PHP is single threaded?
- Options API get_option() and update_option() Not Correctly Updating or Returning
- wp_head function not outputting
- How to make own crop image function for WordPress plugin
- How can I hide that I Use WordPress (with W3 Total Cache)
- Why does wp_head hook my functions to the beginning of my source code?
- Pass argument to event hook
- wp_insert_post: array only. wp_update_post: array|object (?)
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- Building a REST API for your web app exposes primary keys of DB records?
- Custom meta box values are not getting saved for my custom post type
- Why does the post_type_link hook everything twice?
- Send notification email to admin for every new post published
- Adding function to child theme’s function.php
- Custom Registration username_exists / email_exists
- How can I search all plugins for composer’s vendor/autoload.php?
- Action Hook Inside WordPress Plugin Shortcode
- Add a custom class to the body tag using custom fields
- Why doesn’t global $wp_query not get hooked?
- Submit form to db
- Add a custom WooCommerce settings tab with sections
- PHP using external anonymous function inside class
- Using ACF Relationship field to set post type to draft or published status
- How do I add a function to parent theme
- Add Pre-Defined Value to Click Counter in WordPress
- How can i avoid duplicate same post in wp?
- Drop down question
- code that I can run, or a plug in to show what sql tables something pulls information from
- Automatic email message after manual user approval
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- Custom meta box is not displaying value showing tag as empty
- custom mailchimp form using HTTP API
- How to override theme’s public static function inside of a trait?
- pass datetime using wp_localize_script to frontend from settings page
- add custom metabox to media library custom widget
- Display attached images of a page or post that are insetred using gallery
- overwrite wordpress gallery with custom gallery shortcode
- Enqueue sripts and styles only if function is called
- Add widget area from visual editor
- Looping through custom data in a custom table to display all items in a post
- not able to access $_POST on backend profile update
- Custom Plugin Develoment, Form Action
- WordPress Query Crashes Browser
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- Plugin Modification Change Functionality For Logged User Only
- How can I move the posted-on date above the post and below the entry-header?
- INCOMING: Wall of code for form and $_POST, not updating custom field’s value
- add shortcode heading showing multiple time
- Post formating on Home page
- calling a function from a class in your template
- WP multisite network plugin fails to see classes loaded with spl autoload
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- What is this mark for “? function()” [closed]
- using a shortcode in a hyperlink
- Login user into magento using wordpress account
- Customize create table SQL statement in any WordPress plugin
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only