enqueue script and css file in child-theme or main plugin file in worpress
FOR Child theme
wp_enqueue_script( 'theme_js', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' ));
}
add_action('wp_enqueue_scripts', 'theme_js');
FOR main plugin file
function ecom_scripts(){
wp_enqueue_script("jquery");
wp_enqueue_script( 'foundation-script', plugins_url('/slider/foundation.min.js', __FILE__));
wp_enqueue_script( 'slick-script', plugins_url('/slider/slick.min.js', __FILE__));
// wp_enqueue_style( 'foundation-style', plugins_url('/slider/foundation.css', __FILE__));
wp_enqueue_style( 'slick-style', plugins_url('/slider/slick.css', __FILE__));
wp_enqueue_script( 'ecom-script', plugins_url('/js/custom.js', __FILE__));
wp_localize_script( 'ecom-script', 'myajax', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
wp_enqueue_style( 'ecom-style', plugins_url('/css/stylesheet.css', __FILE__));
}
add_action("wp_enqueue_scripts","ecom_scripts");
Comments
Post a Comment