0

This plugin works on my live wordpress instance. However, on my local machine, none of the javascript is getting triggered. I think it has to do with plugins_url and it most likely not returning the correct path. How can I fix this?

    wp_register_script('consultant_scheduler', plugins_url('/js/scripts.js', __FILE__), array( 'jquery' ));
wp_enqueue_script('consultant_scheduler');

} add_action('admin_enqueue_scripts', 'consultant_scheduler_scripts'); add_action('wp_enqueue_scripts', 'consultant_scheduler_scripts');

3
  • How do you know it's returning the incorrect path? Have you inspected the page to see if the script is being added to the page? Are there errors in the console? Feb 2, 2019 at 1:10
  • From what I can see, the script is not being added to the page at all. In the live instance, when I check what scripts are being run, the plugins folder appears with the appropriate script files. On my local machine, it's not displaying.
    – Hani Honey
    Feb 2, 2019 at 1:14
  • According to codex, you don't need to put '/' at the begining of the first plugins_url parameter. wp_register_script function returns a boolean value whether the script has been registered. Did you check it?
    – anton
    Feb 2, 2019 at 19:45

0

Your Answer

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