Scroll to top

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”);

Leave a Reply

Your email address will not be published. Required fields are marked *