[英]Wordpress Include jQuery UI Checkboxradio for frontend theme functions.php
我有一個問題,jQuery UI和jQuery主題沒有加載。
我使用最新的Wordpress 4.6。 在我的主題文件夾中使用Functions.php,我添加了這段代碼:
function jquery_frontend_scripts() {
global $wp_scripts;
wp_enqueue_script('jquery-core');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-checkboxradio');
$queryui = $wp_scripts->query('jquery-ui-core');
$url = "//ajax.googleapis.com/ajax/libs/jqueryui/".$queryui->ver."/themes/base/jquery-ui.css";
wp_enqueue_style('jquery-ui-base', $url, false, null);
}
if (!is_admin()) add_action('wp_enqueue_scripts', 'jquery_frontend_scripts');
在wordpress管理員的聯系人7頁面上我添加了:
<script>
jQuery(function() {
jQuery( "input" ).checkboxradio({
icon: false
});
} );
</script>
<legend>Välj belopp: </legend>
<label for="radio-50">50 kr</label>
<input type="radio" name="radio-50" id="radio-50">
<label for="radio-200">200 kr</label>
<input type="radio" name="radio-200" id="radio-200">
<label for="radio-500">500 kr</label>
<input type="radio" name="radio-500" id="radio-500">
正在調用該函數。 所以我猜jQuery UI或者jQuery Theme無法正確加載一定有問題。 謝謝!
wp_enqueue_script( '的jquery-UI-checkboxradio');
我沒有在參考https://developer.wordpress.org/reference/functions/wp_enqueue_script/中看到依賴項
不是嗎
jQuery的UI按鈕
要么
的jquery-UI-形式
您是否嘗試過指定腳本的源代碼,並將其作為函數wp_enqueue_script
的第二個參數wp_enqueue_script
?
請參閱文檔 。
我有點晚了,但如果你沒找到答案,你的jquery-ui“基礎”風格的網址是不正確的。 wordpress中jquery ui的當前版本是1.11.4。 如果你去//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/base/jquery-ui.css,你會得到一個404.我沒有看到基本樣式可以通過http獲得://code.jquery.com/ui/版本1.11.4,但它適用於版本1.12.1。 所以我建議選擇不同的風格或者看看基本風格的最新穩定版本是否有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.