WP:如何删除 wp_enqueue_script 中的版本号? [英] WP: how to remove version number in wp_enqueue_script?
问题描述
我正在尝试从 wp_enqueue_script
生成的 URL 中删除版本号.似乎我应该在每个 http://codex 的第四个参数上传递一个 null
.wordpress.org/Function_Reference/wp_enqueue_script:
I'm trying to remove the version number from appearing in the URL generated by wp_enqueue_script
. It seems like I should pass a null
on the 4th parameter per http://codex.wordpress.org/Function_Reference/wp_enqueue_script:
wp_enqueue_script('jquery', false, array(), null, false);
它不起作用.我仍然看到版本号.我如何删除它?
It's not working. I still see the version number. How do I remove that?
另外,我如何使用 wp_enqueue_script
以便从 Google CDN 获取 jQuery?
Also, how do I use wp_enqueue_script
so that I get jQuery from the Google CDN?
推荐答案
你可以使用
wp_enqueue_script('jquery', 'URL', array(), '', false);
或
wp_enqueue_script('jquery', 'URL', array(), null, false);
或者你可以放置一个通用名称占位符
or you can put a generic name placeholder
wp_enqueue_script('jquery', 'URL', array(), 'custom', false);
但特别是对于jquery",如果您想替换它,我会取消注册默认值
But particularly with "jquery" I would deregister the default if you want to replace it
wp_deregister_script('jquery');
$GoogleJqueryURI = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
wp_register_script('jquery', $GoogleJqueryURI, array(), 'custom', false);
wp_enqueue_script('jquery');
这篇关于WP:如何删除 wp_enqueue_script 中的版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!