条件付き(ブラウザ固有)JavaScriptファイルを登録してエンキューしますか?
WP.SEコミュニティは常にの使用をお勧めしているwp_register_scriptとwp_enqueue_script(と同様に、テーマ/テンプレートにスクリプトを追加するwp_register_styleと、wp_enqueue_styleスタイルシートのため)。 これは、スクリプトを登録してエンキューする方法です... 最初に、私はfunctions.phpにこのようなものを追加します add_action('init','wpse54189_register_script'); function wpse54189_register_script(){ //Register scripts wp_enqueue_script( 'jquery' ); wp_register_script( 'aahan_bootstrap_transition', get_template_directory_uri().'/js/bootstrap-transition.js'); wp_register_script( 'aahan_bootstrap_carousel', get_template_directory_uri().'/js/bootstrap-carousel.js', array('aahan_bootstrap_transition')); wp_register_script( 'wpse54189_ajax_comment', get_template_directory_uri().'/js/no-reload-comments.js'); } 次に、次のようにテンプレートファイル(たとえば、header.php)で呼び出します。 <?php wp_enqueue_script( 'aahan_bootstrap_carousel' ); ?> <?php wp_enqueue_script( 'wpse54189_ajax_comment' ); ?> さて、要点を説明しますが、特定のブラウザによって認識される「条件付きJavaScriptファイル」を登録してエンキューするにはどうすればよいですか?例えば: <!--[if lt IE 9]> <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script> <![endif]--> これを適切に登録してエンキューするにはどうすればよいですか? PS:私はAutomatticのテーマラングラーによって開発されたReddleテーマを使用しています。そして、テーマのheader.phpは、前述のコードを直接使用します-つまり、エンキューされません。だから、それはそれを行う唯一の方法だということですか?