Skip to content Skip to sidebar Skip to footer

Script Not Included With Wp_enqueue_scripts

I have learned to include scripts the following way. add_action( 'wp_enqueue_scripts', 'woomps_ajax_frontend' ); function woomps_ajax_frontend() { wp_enqueue_script( 'woomps_s

Solution 1:

Can you please try this plugin_dir_url(__FILE__) insted of plugins_url().

add_action( 'wp_enqueue_scripts', 'woomps_ajax_frontend' );

functionwoomps_ajax_frontend() {

    wp_enqueue_script( 'woomps_sub_slider', plugin_dir_url(__FILE__). 'js/woomps-ajax-frontend.js' , array('jquery'), '1.0', true );

    $parameters =  array(
        'ajax_url' => admin_url( 'admin-ajax.php' ),
        );
    wp_localize_script( 'woomps_sub_slider', 'subpost', $parameters);


}

Solution 2:

The PHP code was put in an included (required_once) file which i had enqueue the following way.

functionwoomps_scripts() { 
require_once ('includes/woomps-ajax-sub-chooser.php'); 
} //END woomps_scripts

add_action('wp_enqueue_scripts','woomps_scripts');

If I put the require_once ('includes/woomps-ajax-sub-chooser.php'); outside this function woomps_scripts it got included.

So it seems I cant do wp_enqueue_scripts two times down.

Post a Comment for "Script Not Included With Wp_enqueue_scripts"