2017-04-26 3 views
0

私のウェブサイトはCSSファイルを読み込んでいますが、jsは読み込んでいません。 私のheader.phpの:ワードプレスwp_enqueueはCSSを読み込んでいますが、jsはありません

<!doctype html> 
<html class="no-js" lang="de-DE"> 
<head> 
    <meta charset="UTF-8"> 
    <title>//</title> 
    <?php wp_head(); ?> 

</head> 

と私のfunctions.php:

<?php 

    function include_all() { 
     wp_enqueue_style('app', get_template_directory_uri() . '/css/app.css',false,'1.1','all'); 
     //--- 
     wp_deregister_script('jquery'); 
     wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-2.2.4.min.js', array(), null, true); 
     //--- 
     wp_enqueue_script('app', get_template_directory_uri() . '/js/app.js', array('jquery'), null, true); 


    } 
    add_action('wp_enqueue_scripts', 'include_all'); 

?> 

私は自分自身のバージョンを使用してWordPressのjqueryのを無効にしたいが、そのだけCSSを読み込みます。これは、Wordpressにjs & cssを含めるための最良の方法ですか?

ご協力いただきありがとうございます。ご協力いただきありがとうございます。

答えて

0

jsファイル&を登録してからエンキューしてください。この例を試してください。

function include_all() { 

wp_register_script('app', get_template_directory_uri() . '/js/app.js', array('jquery'), null, true); 
wp_enqueue_script('app'); 
} 
add_action ('wp_enqueue_scripts', 'include_all'); 
+0

not working sry:/ –

+0

エンキューパラメータwp_enqueue_script($ handle、$ src、$ deps、$ ver、$ in_footer)を確認してください。 wp_register_script( 'app'、get_template_directory_uri()。 '/js/app.js')で正しく定義します。 wp_enqueue_script( 'app'); –

0

「jquery」の名前はすでに予約されています。 (Dは、index.phpの中で

wp_enqueue_script( 'アプリ'、get_template_directory_uriを()<?php wp_footer(); ?>を追加するのを忘れ '/js/app.js'、配列:。この、1

wp_enqueue_script('custom-jquery', 'https://code.jquery.com/jquery-2.2.4.min.js', array(), null, true); 

wp_enqueue_script('app', get_template_directory_uri() . '/js/app.js', array('custom-jquery'), null, true); 
+0

not working sry:/ –

0

大丈夫その今作業を使用します'custom-jquery')、null、true);

関連する問題