0

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>
Johannes
67.9k22 gold badges84 silver badges139 bronze badges
asked Apr 6, 2018 at 21:38
2
  • Possible duplicate of How to add custom css/js to just one page in WordPress? Commented Apr 6, 2018 at 21:59
  • 1
    Are 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) Commented Apr 9, 2018 at 14:26

2 Answers 2

1

The line in header.php which calls the stylesheet should be like this:

<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>">
answered Apr 10, 2018 at 22:14
Sign up to request clarification or add additional context in comments.

1 Comment

With this line, you don't even need anything in functions.php at all, right?
0

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!

answered Apr 10, 2018 at 22:36

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.