I create three files: functions.php, style.css, header.php But header.php didn't see style.css
In functions.php I write
/**
* Enqueue scripts and styles.
*/
function newtheme_scripts()
{
wp_enqueue_style('newtheme-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'newtheme_scripts' );
style.css
* {
background-color: black;
}
.container-fluid {
padding: 0px;
}
Also here is my header.php
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Golden</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="<?php echo get_stylesheet_uri() ?>">
<?php wp_head(); ?>
</head>
<body>
<div class="row header">...</div></body></html>
-
Possible duplicate of How to add custom css/js to just one page in WordPress?Jose da Silva Gomes– Jose da Silva Gomes2018年04月06日 21:59:47 +00:00Commented Apr 6, 2018 at 21:59
-
1Are you using wp_head() in your header.php file? It should be immediately before the </head> tag. For further help, please also share your header.php file and ideally, the template file calling the head (ex. index.php)Myles– Myles2018年04月09日 14:26:03 +00:00Commented Apr 9, 2018 at 14:26
2 Answers 2
The line in header.php which calls the stylesheet should be like this:
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>">
1 Comment
First off, you do not need to call your stylesheet after enqueuing it, the wp_enqueue_scripts hook should inject your stylesheet call inside your header somewhere.
It looks like your header is set up correctly, with the wp_head(); call in the right area. However, I believe the culprit lies somewhere in how the theme itself is set up.
You had mentioned that you created these files (header.php, functions.php, and style.css)... generally speaking these files should already be created for you within the theme itself (except for maybe the style.css, if you're working with a child theme).
Hope this helps! Good luck!