Scroll to top

How to enqueue script and css file in child-theme and main plugin file in worpress?


Notice: Undefined variable: string in /home/u665484253/domains/wpcodekit.com/public_html/wp-content/themes/twentytwenty-child/functions.php on line 61

How to enqueue script and css file in child-theme and main plugin file in worpress?

 

FOR Child theme

function theme_js() {
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”);

enqueue script and css file in child-theme and main plugin file in worpress?

Read More Posts

Leave a Reply

Your email address will not be published.