How to enqueue JavaScripts in a plugin in WordPress? To load the script in frontend, use wp_enqueue_scripts action (which is not the same that wp_enqueue_script()
function:
1 2 3 4 5 6 |
function fwm_widget_enqueue_script() { wp_enqueue_script( 'my_custom_script', plugin_dir_url( __FILE__ ) . 'js/jquery.repeatable.js', array('jquery'), '1.0.0', false ); } add_action('admin_enqueue_scripts', 'fwm_widget_enqueue_script'); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.