简体   繁体   中英

How to correctly use = wp_enqueue_style with a CDN in wordpress?

My current code:

wp_enqueue_style( 'script-css', plugins_url( 'script/myscript.js', __FILE__ ));

My goal: Instead of loading the file from the plugins directory, I want to load above script file from http://mycloudfronturl.net/myscript.js

But somehow I am messing with either the quotes or while replacing the plugins_url. I am not a hard code php coder, so can someone tell me what to do please?

Use enqueue_script instead. Sample example:

wp_register_script('some_script', 'http://anywhereyouwant.com');
wp_enqueue_script('some_script');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM