bootstrap.min.jsをネイティブワードプレスjqueryに依存させることができますが、Jquery 1.11.1はソースコードには表示されず、フォントAwesomeも機能しません正しくwp_enqueue_script - 追加のJqueryがソースコードに表示されない
私はstackoverflowの中の他の質問からいくつかのコードを試してみたが、私はまだ、私は以下のコードにいくつかのコメントを入れて、私の質問
を解決することはできません。
更新されたコード
function enqueue_jquery() {
// deregister jquery ok
wp_deregister_script('jquery'); // unregister the WP-provided jQuery version
// tag is not added in code
wp_enqueue_script(
'jquery',
get_template_directory_uri() . '/js/jquery.js',
array(), // don't make jquery dependent on jquery...!
'1.11.1',
true
);
}
add_action('wp_enqueue_scripts', 'enqueue_jquery');
function enqueue_styles_scripts() {
//its OK
wp_enqueue_style(
'style-theme',
get_stylesheet_uri(),
array('bootstrap-css')
);
//its OK
wp_enqueue_style(
'bootstrap-css',
get_template_directory_uri() . '/css/bootstrap.min.css'
);
//its OK
wp_enqueue_style(
'stylish-portfolio',
get_template_directory_uri() . '/css/othercss.css'
);
//I changed the directory of the files to css and fonts folders and it worked correctly
wp_enqueue_style(
'font-awesome',
get_stylesheet_directory_uri() . '/css/font-awesome.css'
);
//Appears in header but is working correctly
wp_enqueue_script(
'bootstrap-js',
get_template_directory_uri() . '/js/bootstrap.min.js',null
);
}
add_action('wp_enqueue_scripts', 'enqueue_styles_scripts');
//Its Ok
function wpse_ie_conditional_scripts() { ?>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<?php
}
add_action('wp_head', 'wpse_ie_conditional_scripts');
?>
これは、作品を言っていますか?あなたはまだjQueryの登録を解除しています - WPフックの外で... bootstrap.min.jsのjquery要件を削除したことに気付きました。 - 確かにwinceのブートストラップは動作しません。* jqueryが必要です... 'wp_enqueue_script( 'bootstrap- js '、get_template_directory_uri()。' /js/bootstrap.min.js '、array(' jquery ')); '? – MacPrawn
はい私の作品、ソースコード ' 'と' Bootstrap.min.js'は完全に動作しています – Gislef