2017-03-08 8 views
-1

ねえみんな私は無駄に次のアプローチを試みた。カスタム作成されたwordpressテーマではstyle.cssが呼び出されませんか?

まず

<?php 
    wp_head(); 
    wp_enqueue_style("style.css",get_template_directory_uri()); 
?> 

セカンド

<?php 
    wp_head(); 
    wp_enque_style("style.css",get_stylesheet_uri()); 
?> 

サード

<?php 
    wp_head(); 
    function my_assets() { 
     wp_enqueue_style('style' , get_template_directory_uri() .'/style.css'); 
    } 

    add_action('wp_enqueue_scripts', 'my_assets'); 
    do_action("wp_enque_scripts"); 
?> 

ディレクトリ構造

hospital_theme[ 
    style.css 
    index.php 
    header.php 
    footer.php 
    sidebar.php 
] 

テーマは、htmlファイルからwordpressテーマに変換されるカスタムユーザーが作成したものです。現在テーマには、header.php、footer.php、sidebar.php、index.php、style.cssの5つのファイルのみが含まれています。

私は、それぞれのファイルの内容を正常に呼び出すためにget_header()、get_footer()を使用しました。 WP管理者で

答えて

1

を置く当社は、テーマディレクトリ内functions.phpと呼ばれる新しいファイルを作成します。 functions.php

function wpdocs_theme_name_scripts() { 
    wp_enqueue_style('style-name', get_stylesheet_uri().'/style.css'); 
} 

add_action('wp_enqueue_scripts', 'wpdocs_theme_name_scripts'); 
+0

は動作しませんでした – phpNoob

-1

:外観>エディタ> header.phpのと簡単なHTML <link src=""...>
My print Screen

1

に次のコードを入力してくださいCSSを追加するもう一つの方法があります。 header.phpファイルに次のコードを追加することができます。

<link href="<?php echo get_template_directory_uri(); ?>/style.css" type="text/css" rel="stylesheet"> 
0

以下のコードを使用できます。通常、header.phpファイルにこのコードを使用してロードされます。

<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url'); ?>" /> 

ご希望の場合はご利用ください。

関連する問題