Skip to content Skip to sidebar Skip to footer

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

http://www.northwindcomputing.com/wp-content/plugins/ndm-mini-storage-calc/ndm-mini-storage-calc/ndm-mini-storage-calculator.js?ver=3.9

While the script is located at

http://www.northwindcomputing.com/wp-content/plugins/ndm-mini-storage-calc/ndm-mini-storage-calculator.js?ver=3.9

the plugin path is added twice.

Post a Comment for "My First Wordpress Plugin - Can't Get Script To Run"