My First Wordpress Plugin - Can't Get Script To Run
I thought this would be really simple but have spent a few days and am stuck. The idea is to insert a form on a page via shortcode; the form calculates totals from user input. The
Solution 1:
Remove the plugin URL, plugins_url
will get that for you.
It's also a good idea to load files on init
add_action('init', 'load_ndm_mini');
functionload_ndm_mini(){
wp_register_script( 'ndm-mini-storage-calculator', plugins_url('ndm-mini-storage-calculator.js', __FILE__ ) );
wp_enqueue_script( 'ndm-mini-storage-calculator' );
}
If you open the console, you'll notice the url looks like
While the script is located at
the plugin path is added twice.
Post a Comment for "My First Wordpress Plugin - Can't Get Script To Run"