19 September 2019

How to link css,jquery and ajax with all files via one wordpress function?

link css,jquery and ajax with all files via one wordpress function

copy this code in wordpress function.php file or main plugin file?



function ecom_scripts(){

wp_register_script( 'ecom-script', plugins_url('/js/custom.js', __FILE__), array( 'jquery' ), '', true );
    wp_localize_script( 'ecom-script', 'myajax', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
    wp_enqueue_script( 'ecom-script' );
wp_register_style( 'ecom-style', plugins_url('/css/stylesheet.css', __FILE__), true );
    wp_enqueue_style( 'ecom-style' );
}
add_action("wp_enqueue_scripts","ecom_scripts");

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...