[英]stylesheet not importing in wordpress
I was just going through this tutorial HERE and basically the author recommends that the css stylesheet be imported like so: 我刚刚在这里阅读本教程,基本上作者建议像这样导入css样式表:
function theme_enqueue_styles() {
wp_register_style( 'custom-style', get_template_directory_uri() . '/style.css', array(), '20120208', 'all' );
wp_enqueue_style('custom-style' );
} }
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); add_action('wp_enqueue_scripts','theme_enqueue_styles');
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
My header.php of my theme looks like so: 我的主题的header.php看起来像这样:
<!doctype html>
<html <?php language_attributes(); ?> >
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><?php bloginfo('name'); ?></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header class="site-header">
<h1><a href="<?php echo home_url(); ?>"></a><?php bloginfo('name'); ?></h1>
<h5><?php bloginfo('description'); ?></h5>
</header>
But i am still not seeing the effect of my stylesheet , can anybody point me to what exactly am i doing wrong ? 但我仍然没有看到我的样式表的效果,任何人都可以指出我到底做错了什么?
EDIT:: On further inspection i found out that if i post the contents of header.php in index.php the stylesheet is loading fine , which means that my functions.php files is working fine. 编辑::进一步检查我发现,如果我在index.php中发布header.php的内容,样式表加载正常,这意味着我的functions.php文件工作正常。 So i guess the problem is with my header.php file, I have updated above what my header.php file looks like, so can somebody tell me whats wrong with my header.php file now ?
所以我想问题是我的header.php文件,我已经更新了我的header.php文件的样子,所以有人可以告诉我我的header.php文件现在有什么问题吗?
Thank you. 谢谢。
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
It should be: 它应该是:
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_register_style( 'custom-style', get_template_directory() . '/style.css');
wp_enqueue_style('custom-style' );
}
The style.css is in your root folder of the theme, am I right? style.css在主题的根文件夹中,对吗?
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_register_style( 'parent-style', get_template_directory_uri() . '/styles.css', array(), false, 'screen' );
wp_enqueue_style( 'parent-style' );
}
问题是我没有像这样导入标头:
get_header();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.