0

I am trying to load some scripts in the front-end. Been trying the code below (and variations of it) but doesn't do anything. Otherwise, the plugin is loading fine (using custom shortcode).

class MyPluginClass {   
    function load_scripts() {
        wp_enqueue_script('any_unique_id_is_ok', plugins_url('/somefolder/somefile.js', __FILE__),array('jquery'));
    }
}
add_action('wp_enqueue_scripts', array('MyPluginClass','load_scripts'));

Any help would be highly appreciated. Thanks!

4
  • Try: wp_enqueue_script('any_unique_id_is_ok', plugins_url('/somefolder/somefile.js', FILE),array('jquery'),null,false); Commented Nov 22, 2018 at 14:09
  • Sorry not working Commented Nov 22, 2018 at 14:22
  • Try taking "load_scripts" outside of class. Commented Nov 22, 2018 at 18:42
  • Yeah tried that as well. Didn't work sadly. Commented Nov 22, 2018 at 19:43

1 Answer 1

1

For those who might stumble upon this issue, the problem was the missing wp_head() and wp_footer() hooks in my custom theme. Put these into the relevant places and everything should work fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.