0

I keep getting the following message in the browser Fatal error: Call to undefined function plugin_url() in

My code at present:

add_action( 'wp_enqueue_script', 'load_jquery2' );
function load_jquery2() {
    wp_enqueue_script( 'jquery' );    }  


function add_my_css_and_my_js_files(){
        wp_enqueue_script('jquery-validate-min', plugin_url('/activate/jquery_validate_min.js', __FILE__ ) );
 }
  add_action('wp_enqueue_scripts', "add_my_css_and_my_js_files"); 

The plugin is in a folder called 'activate' & the JS is in that folder directly, not a sub folder.

2 Answers 2

2
function add_my_css_and_my_js_files(){
    wp_enqueue_script('jquery-validate-min', plugins_url('activate/jquery_validate_min.js', __FILE__ ) );
}
add_action('wp_enqueue_scripts', "add_my_css_and_my_js_files"); 
  1. You need to use the plugins_url() function (you are missing the s at the end of plugins).
  2. Reference the location of the script file with the relative path. Meaning the path should be activate/jquery_validate_min.js.
1
  • 1
    yeah, you are right. did not see the additional slash.
    – fischi
    Commented Jan 28, 2014 at 16:28
2

The function you are looking for is called plugins_url() (ref), with the additional s. Should be fine afterwards.

Your Answer

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