2015-02-11 78 views
0

我想问为什么我的样式表不显示在网页的页面源。请参阅下面的代码,这是我的functions.php中的代码。在WordPress中添加样式表

`function theme_styles() { 

     wp_enqueue_style('main', get_template_directory_uri() . '/style.css'); 
    } 

    add_action('wp_enqueue_scripts', 'theme-styles');` 

我相信我输入了正确的代码,但每当我在网页上点击右键并寻找源代码,我的样式表没有显示。我正在使用WebMatrix,我的style.css位于我目前正在使用的主题文件夹下。我是WordPress新手,我正在尝试创建自己的自定义主题。任何帮助将不胜感激。

太感谢你了,

吉尔伯特雅各

回答

0

没关系,我发现我的theme_styles使用下划线和我在动作用一个主题风格。谢谢!

1

试试这个:

function my_theme_load_resources() { 
    $theme_uri = get_template_directory_uri(); 
    wp_register_style('style_css', $theme_uri.'/style.css', false, '0.1'); 
    wp_enqueue_style('style_css'); 
} 
add_action('wp_enqueue_scripts', 'my_theme_load_resources'); 
2

试试这个:

wp_enqueue_style('themename-style', get_stylesheet_uri());